R 脚本/调查数据:查找同级并记录该同级姐妹<=1 岁时



我想在调查数据中找到一个孩子的兄弟姐妹,检查是否有年龄为<= 1岁的兄弟姐妹,并存储结果(1,0)。

这是我的数据:

<表类> 集群 house_number 年龄 tbody><<tr>1501511841214121122202360250252253

你的意思是:


# let's call your dataframe : data
# we create a new column called sibling_age on the condition of the age column
# and we use the ifelse function
# the first value represents the if argument
# the second value represents the else argument
data$sibling_age = ifelse(data$age>1,1,0)

# I hope that this is what you were looking for.

相关内容

最新更新