library(dplyr)
data(survey_data)
# Does the satisfaction-income correlation survive controlling for age?
partial_cor(survey_data, life_satisfaction, income, controls = age)
# Several variables, several controls
partial_cor(survey_data, trust_government, trust_media, trust_science,
controls = c(age, political_orientation))
# Weighted (SPSS WEIGHT BY)
partial_cor(survey_data, life_satisfaction, income,
controls = age, weights = sampling_weight)
# Grouped (SPSS SPLIT FILE)
survey_data %>%
group_by(gender) %>%
partial_cor(life_satisfaction, income, controls = age)
# --- Three-layer output ---
result <- partial_cor(survey_data, life_satisfaction, income, controls = age)
result # compact overview
summary(result) # full detailed output
Run the code above in your browser using DataLab