Deriving Quantiles or Percentiles in R

Percentiles can be calculated in R using the quantile function. The function has the argument type which allows for nine different percentile definitions to be used. The default is type = 7, which uses a piecewise-linear estimate of the cumulative distribution function to find percentiles.

This is how the 25th and 40th percentiles of aval could be calculated using the default type.

quantile(aval, probs = c(0.25, 0.4))
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.2 (2024-10-31)
 os       macOS Sequoia 15.6.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/London
 date     2025-10-13
 pandoc   3.4 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)

─ Packages ───────────────────────────────────────────────────────────────────
 ! package     * version date (UTC) lib source
 P BiocManager   1.30.25 2024-08-28 [?] CRAN (R 4.4.1)
 P cli           3.6.3   2024-06-21 [?] CRAN (R 4.4.0)
 P digest        0.6.37  2024-08-19 [?] CRAN (R 4.4.1)
 P evaluate      1.0.0   2024-09-17 [?] CRAN (R 4.4.1)
 P fastmap       1.2.0   2024-05-15 [?] CRAN (R 4.4.0)
 P htmltools     0.5.8.1 2024-04-04 [?] CRAN (R 4.4.0)
 P htmlwidgets   1.6.4   2023-12-06 [?] CRAN (R 4.4.0)
 P jsonlite      1.8.9   2024-09-20 [?] CRAN (R 4.4.1)
   knitr         1.50    2025-03-16 [1] RSPM (R 4.4.0)
   renv          1.0.10  2024-10-05 [1] CRAN (R 4.4.1)
 P rlang         1.1.6   2025-04-11 [?] RSPM
 P rmarkdown     2.28    2024-08-17 [?] CRAN (R 4.4.0)
 P rstudioapi    0.16.0  2024-03-24 [?] CRAN (R 4.4.0)
 P sessioninfo   1.2.2   2021-12-06 [?] CRAN (R 4.4.0)
   xfun          0.52    2025-04-02 [1] RSPM (R 4.4.0)
 P yaml          2.3.10  2024-07-26 [?] CRAN (R 4.4.0)

 [1] /Users/christinafillmore/Documents/GitHub/CAMIS/renv/library/macos/R-4.4/aarch64-apple-darwin20
 [2] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library

 P ── Loaded and on-disk path mismatch.

──────────────────────────────────────────────────────────────────────────────