Selecting parts of variables Hi all. Maybe some of you may be able to help me.
How do I select parts of a variable?
Specifically, I have a column in a data frame (csv) that corresponds to race. 1 = Caucasian, 2 = African Amer. etc. for a range of 1-9 for the variable.
I was able to separate them individually like this:
black <- df[df[, "race"] == 2,]
white <- df[df[, "race"] == 1,]
hisp <- df[df[, "race"] == 6,]
but I want a new dataframe that includes all three of these segments. Or write a code that goes into my raw dataframe and selects just those three.
I unsuccessfully tried
races_used <- c(df[df[, "race"] == 1,],df[df[, "race"] == 2,],df[df[, "race"] == 6,])
and
race2 <- filter(df, [df$race == [1,2,6]])
Any help would be appreciated.