# Load required packages and data
library(dplyr)
data(survey_data)
# Basic weighted quantiles (0%, 25%, 50%, 75%, 100%)
survey_data %>% w_quantile(age, weights = sampling_weight)
# Custom quantiles
survey_data %>% w_quantile(income, weights = sampling_weight, probs = c(0.1, 0.5, 0.9))
# Multiple variables
survey_data %>% w_quantile(age, income, weights = sampling_weight)
# Grouped data
survey_data %>% group_by(region) %>% w_quantile(age, weights = sampling_weight)
# Unweighted (for comparison)
survey_data %>% w_quantile(age)
Run the code above in your browser using DataLab