# usage of 'groups', 'rownames'
data(mtcars)
# add labels to dataset
mtcars %>%
apply_labels(mpg = "Miles/(US) gallon",
disp = "Displacement (cu.in.)",
wt = "Weight",
hp = "Gross horsepower",
vs = "Engine",
vs = num_lab("
0 V-engine
1 Straight engine
"),
am = "Transmission",
am = num_lab("
0 Automatic
1 Manual
")
) %>%
split_by(am, vs) %>%
to_list({
res = lm(mpg ~ hp + disp + wt, data = .x)
cbind(Coef. = coef(res), confint(res))
}) %>%
split_off(groups = TRUE, rownames = "variable")
Run the code above in your browser using DataLab