Reputation: 17
I have a column of data listing various education levels from census data, they vary from "HS grad" to "Doctorate" to "9th" for the highest level of education the person received.
I want to create a dummy variable for whether someone is educated or not, and in the "educated=YES" category I want it to list the respondents with college or vocational school backgrounds. I've tried using "&" but it won't group them.
C <- data.frame(educated=census$education=="Assoc-acdm" & "Assoc voc" & "Bachelors" & "Doctorate" & "Masters" & "Prof-school")
Anyone know how do group non-numeric responses?
Upvotes: 0
Views: 887
Reputation: 44299
Instead, you would want:
C <- data.frame(educated=(census$education %in% c("Assoc-acdm",
"Assoc voc", "Bachelors", "Doctorate", "Masters", "Prof-school")))
Upvotes: 4