Hi I've been trying to recode numerical variables into categorical.
For example, using mtcars, I am trying to divide mpg into 2 category < 25 & =>25
These are the codes that I've tried, but getting error message.
data=mtcars
summary(mtcars$mpg)
Min. 1st Qu. Median Mean 3rd Qu. Max.
10.40 15.43 19.20 20.09 22.80 33.90
mpgcat <- cut(mpg, breaks = (0,24.99,34), labels = c("0","1"))
Error: unexpected ',' in "mpgcat <- cut(mpg, breaks = (0,"
breaks = (0, 24.99,34)you needbreaks = c(0,24.99,34). Voting to closse as typo. - Gregor Thomascut(mtcars$mpg, breaks = c(0,24.99,34), labels = c("0","1"))- Mako212