if (FALSE) {
data(mtcars)
mtcars = apply_labels(mtcars,
mpg = "Miles/(US) gallon",
cyl = "Number of cylinders",
disp = "Displacement (cu.in.)",
hp = "Gross horsepower",
drat = "Rear axle ratio",
wt = "Weight (1000 lbs)",
qsec = "1/4 mile time",
vs = "Engine",
vs = c("V-engine" = 0,
"Straight engine" = 1),
am = "Transmission",
am = c("Automatic" = 0,
"Manual"=1),
gear = "Number of forward gears",
carb = "Number of carburetors"
)
expss_output_viewer()
mtcars %>%
tab_cols(total(), am %nest% vs) %>%
tab_cells(mpg, hp) %>%
tab_stat_mean() %>%
tab_cells(cyl) %>%
tab_stat_cpct() %>%
tab_pivot() %>%
set_caption("Table 1. Some variables from mtcars dataset.")
# several tables in a list
list(
cross_cpct(mtcars, list(am, vs, cyl), list(total(), am))
%>% set_caption("Table 1. Percent."),
cross_mean_sd_n(mtcars, list(mpg, hp, qsec), list(total(), am))
%>% set_caption("Table 2. Means.")
) %>%
htmlTable()
expss_output_default()
}
Run the code above in your browser using DataLab