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