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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -