dep_percentiles {deprivateR} | R Documentation |
Calculate Percentiles
Description
Calculate percentiles for a given variable in a data frame. This is the method used to calculate ranked percentiles for SVI.
Usage
dep_percentiles(.data, source_var, new_var)
Arguments
.data |
A tibble containing the data to be used for calculating percentiles. |
source_var |
Required; the quoted or unquoted source variable to be divided into percentiles. |
new_var |
Required; the quoted or unquoted name of the new variable to be created containing the quantile values. |
Value
An updated tibble with the percentiles added as a new column or with replaced values in the source column.
Examples
## load sample data
ndi_m <- dep_sample_data(index = "ndi_m")
# calculate percentiles for population 25 years and older
ndi_m <- dep_percentiles(ndi_m, source_var = B06009_001E,
new_var = pop25_percentile)
# preview the new data
ndi_m[names(ndi_m) %in% c("GEOID", "B06009_001E", "pop25_percentile")]
[Package deprivateR version 0.1.0 Index]