Percentile for a specific value in R

Viewed 17

I can determine the percentiles of a numerical column from a data frame using the quantile() function. However, I do not know how to get the percentile of a specific value from that same column without iteratively plugging in different probs =. How can I determine the percentile for a specific value from a distribution of values?

Example Data

set.seed(1234)
df <- data.frame(matrix(ncol = 1, nrow = 100))
colnames(df)[1] <- "value"
df$value <- rnorm(100, mean = 50, sd = 20)

# calculate percentiles from data frame

quantile(df$value, probs = seq(.1,.9, by = .1))

How would I determine the percentile for a value = 33 based on the distribution of values in df$value?

0 Answers
Related