2
Consider the vector:
x<-runif(30,20,100)
I would like to categorize this vector with the function recode
of package dplyr
. Ranges can be arbitrary. For example:
- from 20 to 50 = 1
- from 51 to 75 = 2
- from 76 to 100 = 3
I know I can use other packages and functions to perform this action. But my intention is specifically to do this with the function recode
of dplyr
. I have tried to do this in many ways, but so far I have not succeeded.
Just to complement this answer, the following information is in the help of version 0.7.8 of
dplyr
(griffins of mine):All replacements **must be the same type**, and must have either length one or the same length as x
. Therefore, you can’t change something from Numeric to factor usingrecode
.– Marcus Nunes