[R] calculating quintile values of numeric data?

Kelly Thompson kt1572757 @end|ng |rom gm@||@com
Wed Jan 23 03:54:14 CET 2019


I’d like to take numeric data, and calculate numeric “quintiles” with
integer values in from 1 – 5 , with values in the lowest 20% of values
having a value of 1, the >20 - <= 40% of values having a value of 2,
the >40% - <=60% of values having a value of 3, etc.

How can I use quantcut, or another function, to do this?


Thanks!


Ex.

x <- c(1:10)

I want:
myquintilefunction (x, q=5, na.rm=T) to return a vector with values:
1,1,2,2,3,3,4,4,5,5

Thanks!



More information about the R-help mailing list