尝试将年龄变量划分为具有此功能的小组。
ifelse(mydata$age <= 25, mydata$age <- "youth",
ifelse(mydata$age <= 35, mydata$age <- "earlyjob",
ifelse(mydata$age <= 55, mydata$age <- "mid-age",
ifelse(mydata$age <= 70, mydata$age <- "latejob", mydata$age <- "senior"))))
但它只是把“青年”和“高级”作为输出......我该怎么办?