# NOT RUN {
data(mtcars)
dfs = mtcars %>% keep(mpg, disp, hp, wt)
with(dfs, w_mean(hp, weight = 1/wt))
# apply labels
dfs = modify(dfs, {
var_lab(mpg) = "Miles/(US) gallon"
var_lab(disp) = "Displacement (cu.in.)"
var_lab(hp) = "Gross horsepower"
var_lab(wt) = "Weight (1000 lbs)"
})
# weighted correlations with labels
w_cor(dfs, weight = 1/dfs$wt)
# without labels
w_cor(unvr(dfs), weight = 1/dfs$wt)
# }
Run the code above in your browser using DataLab