knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The main function in this package has now been incorporated into the official version of the htmlTable package, and development of this package will not longer be supported.
In the htmlTable
package, the htmlTable_td
function has been renamed
to tidyHtmlTable
with additional changes made to parameter names.
See ?tidyHtmlTable
for further details.
# For the dev version of htmlTable install.packages("devtools") devtools::install_github("gforge/tidyhTbl") # For the lastest CRAN release install.packages("htmlTable")
The goal of tidyhTbl is to wrap the htmlTable
function from the
htmlTable
package for use with tidy data.
You can install tidyhTbl from github with:
install.packages("devtools") devtools::install_github("graggsd/tidyhTbl")
This is a basic example which shows you how to solve a common problem:
library(magrittr) library(tidyr) library(dplyr) library(tidyhTbl) library(tibble) 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")) %>% htmlTable_td(header_td = "gear", cgroup1_td = "cyl", cell_value = "value", rnames_td = "summary_stat", rgroup_td = "per_metric")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.