There are several ways to calculate percentiles in R. Here's an example using the quantile() function:
# Example data
data <- c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
# Calculate the 25th, 50th, and 75th percentiles
p25 <- quantile(data, probs = 0.25)
p50 <- quantile(data, probs = 0.50)
p75 <- quantile(data, probs = 0.75)
# Print the results
print(p25)
print(p50)
print(p75)
This code calculates the 25th, 50th (also known as the median), and 75th percentiles of the data vector. The quantile() function takes the dataset and the desired probabilities (in decimal format) as arguments and returns the corresponding percentiles.