# Load required packages and data
library(dplyr)
data(survey_data)
# Basic unweighted analysis
survey_data %>% describe(age)
# Weighted analysis
survey_data %>% describe(age, weights = sampling_weight)
# Multiple variables with custom statistics
survey_data %>% describe(age, income, life_satisfaction,
weights = sampling_weight,
show = c("mean", "sd", "skew"))
# Grouped analysis
survey_data %>%
group_by(region) %>%
describe(age, weights = sampling_weight)
Run the code above in your browser using DataLab