Computes percentiles (quantiles) for selected numeric columns. By default, six bottom percentiles (0th to 0.5th) and six top percentiles (99.5th to 100th) are calculated. The function supports grouping.
percdata(data, cols = NULL, group = NULL, diff = 0.1,
part = "both", na.rm = TRUE, verbose = FALSE)A data frame with rows corresponding to percentiles and columns corresponding to variables (plus a percentile column). If grouped, an additional grouping column is present.
A data frame, matrix, or numeric vector. If a vector, a data frame is created internally.
Column indices or names of numeric variables. If NULL, all numeric columns are used.
Optional grouping column index or name. If provided, percentiles are computed separately for each group.
Common difference between quantile probabilities. Default is 0.1.
Which parts to return: "both" (default), "bottom", or "top". For backward compatibility, part also accepts the integer codes 2 ("both"), 0 ("bottom"), and 1 ("top").
Logical; if TRUE, NA values are removed before quantile computation.
Logical; if TRUE, prints timing message.
Chun-Sheng Liang <[email protected]>
The function uses stats::quantile() on each selected column. For grouped data, percentiles are computed within each group.
1. Example data is from https://smear.avaa.csc.fi/download. It includes particle number concentrations in SMEAR I Varrio forest.
percdata(data, cols = 27:61, group = 4)
Run the code above in your browser using DataLab