# NOT RUN {
library(tidyverse)
mtcars %>%
rownames_to_column %>%
select(rowname, cyl, gear, hp, mpg, qsec) %>%
gather(per_metric, value, hp, mpg, qsec) %>%
group_by(cyl, gear, per_metric) %>%
summarise(Mean = round(mean(value), 1),
SD = round(sd(value), 1),
Min = round(min(value), 1),
Max = round(max(value), 1)) %>%
gather(summary_stat, value, Mean, SD, Min, Max) %>%
ungroup %>%
mutate(gear = paste(gear, "Gears"),
cyl = paste(cyl, "Cylinders")) %>%
tidyHtmlTable(header = "gear",
cgroup1 = "cyl",
cell_value = "value",
rnames = "summary_stat",
rgroup = "per_metric")
# }
Run the code above in your browser using DataLab