coding variable values into classes using R

前端 未结 5 2034
灰色年华
灰色年华 2020-12-09 12:56

I have a set of data in which I need to code values of certain variables (numeric) into 3 classes.

My data set is similar to this but has 60 more variables:

5条回答
  •  没有蜡笔的小新
    2020-12-09 13:12

    I think Greg's answers cover "standard operating procedure", but I find many uses for the findInterval function as well. It naturally returns a number that identifies the interval in the second argument.

     data$int <- findInterval(data$wt, c(179, 200, 300, Inf))
     data
    

提交回复
热议问题