Creating a binary factor form ordinal data in R -
i have ordinal variable ranges 1 through 67
summary(var) min. 1st qu. median mean 3rd qu. max. 1.0 4.0 8.0 10.2 15.0 67.0
i want recode binary variable first level being score of 1
on original variable , second level – all other scores combined.
i assume have use factor()
function, can't figure out how aggregate of values (excluding 1
) second level.
thanks.
yes, factor()
function works. use:
factor(var == 1, labels=c("other", "one"))
the condition split data you, , labels
assign relevant names (otherwise names "false" , "true").
Comments
Post a Comment