## create example data
<testonly>set.seed(1234)</testonly>
x <- rnorm(1000)
## cut into quartiles
quartiles <- quantcut( x )
table(quartiles)
## cut into deciles
deciles <- quantcut( x, seq(0,1,by=0.1) )
table(deciles)
## show handling of 'tied' quantiles.
x <- round(x) # discretize to create ties
stem(x) # display the ties
deciles <- quantcut( x, seq(0,1,by=0.1) )
table(deciles) # note that there are only 5 groups (not 10)
# due to duplicates
Run the code above in your browser using DataLab