I have data in a numerical format and I would like to label them into three levels - "low", "med", "high" based on their quantile
- low, <50% pencentile
- med, 50% < 75% pencentile
- high, > 75% pencentile
This is my R output
quantile(data$crim)
0% 25% 50% 75% 100%
0.006320 0.082045 0.256510 3.677083 88.976200
I use mutate to label them, below is my R code. I got the "high" for all data.
newdata<-mutate(data, crim.lev = ifelse(crim %in% 0:0.26, "low",
ifelse(crim %in% 0.27:3.68, "med",
"high")))
Please let me anything I missed, or other method to do this. Thanks.