Skip to content
Prev 378293 / 398502 Next

calculating quintile values of numeric data?

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!