[英]How do I get the aggregate number of a variable against another variable in R? Both these variables are non-numeric
[英]How do I create a dummy variable in R with non-numeric data?
我有一列数据,列出了人口普查数据中的各种教育水平,从“ HS等级”到“博士学位”再到“ 9th”,代表该人获得的最高教育水平。
我想为某人是否受过教育创建一个虚拟变量,在“ educated = YES”类别中,我希望它列出具有大学或职业学校背景的受访者。 我尝试使用“&”,但不会将它们分组。
C <- data.frame(educated=census$education=="Assoc-acdm" & "Assoc voc" & "Bachelors" & "Doctorate" & "Masters" & "Prof-school")
有人知道如何对非数字响应进行分组吗?
相反,您需要:
C <- data.frame(educated=(census$education %in% c("Assoc-acdm",
"Assoc voc", "Bachelors", "Doctorate", "Masters", "Prof-school")))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.