How do I create group data in a category with more than and less than in R?

后端 未结 1 1203
面向向阳花
面向向阳花 2021-01-16 03:00

I have a data set and I would like to group them in a category... But I would like the category to be more than and less than a certain number?

This is my data set.<

相关标签:
1条回答
  • 2021-01-16 03:17

    Does this work?

    df<- cbind(df, temp_category=cut(df$avg.temp, breaks=c(-Inf,4,5,6,Inf)))
    #the following is more idiomatic
    df$temp_category <- cut(df$avg.temp, breaks=c(-Inf,4,5,6,Inf))
    
    0 讨论(0)
提交回复
热议问题