get.pctile: Determine (Weighted) Percentiles

View source: R/get.pctile.R

get.pctileR Documentation

Determine (Weighted) Percentiles

Description

Given a vector of numbers (a dataset), and one or more specific values of interest, determine at what percentile(s) are those selected values. In other words, what fraction of all of the numbers (actually weighted based on cumulative sum of weights) are smaller than (or tied with) the selected value(s) of interest? Based on analyze.stuff::pct.above (analyze.stuff::pct.above())

Usage

get.pctile(x, values, wts = 1, or.tied = TRUE, na.rm = TRUE)

Arguments

x

Vector of numeric values (the distribution within which percentiles are sought)

values

Required vector of one or more numbers for which percentiles are sought.

wts

Optional weights, default is 1 (equal weighting). Useful to find for example what percent of people have an x score (at or) below a given value.

or.tied

Default is TRUE which means percentile represents what fraction have x at or below value, not just below value.

na.rm

Logical, optional, TRUE by default. Should NA values (missing data) be removed first to get percentile of those with valid (nonmissing) data.

See Also

make.bin.pctile.cols() and assign.pctiles()

Examples

get.pctile(89:95, 1:100)
get.pctile(89:95, 1:100, c(rep(1,90), rep(10000,10)))

ejanalysis/ejanalysis documentation built on April 2, 2024, 10:12 a.m.