To calculate deciles in R, you can use quantile() function with sequence of probability for each decile.

The following method shows how to do it with syntax.

Method: Use quantile() Function

quantile(data, probs = seq(0.1, 0.9, by = 0.1))

seq(0.1, 0.9, by = 0.1) : It generate sequence of numbers from 0.1 to 0.9, incrementing by 0.1.

The following example shows how to calculate deciles in R.

Use quantile() to Calculate Deciles Values of Vector

Let’s see how we can calculate deciles values of vector using quantile() function in R:

# Create vector
data <- c(78,89,85,84,81,79,77,85,85,81,78,89,84,84,81,80)

# Calculate deciles values
d <- quantile(data, probs = seq(.1, .9, by = .1))

# Print deciles
print(d)

Output:

10%  20%  30%  40%  50%  60%  70%  80%  90% 
78.0 79.0 80.5 81.0 82.5 84.0 84.5 85.0 87.0 

The output shows deciles values for vector that we declared in above code.