library(reporter)
library(magrittr)
# Prepare data
dat <- data.frame(stub = rownames(mtcars), mtcars)
dat <- dat[1:15, ]
# Create temp file path
tmp <- file.path(tempdir(), "HairAndEyes2.html")
# Define custom style
sty <- create_style(font_name = "Arial",
font_size = 10,
background_color = "WhiteSmoke",
border_color = "Grey",
title_font_size = 12,
title_font_bold = TRUE,
title_font_color = "SteelBlue",
table_header_background = "Tan",
table_header_font_bold = TRUE,
table_header_font_color = "White",
table_body_background = "White",
table_body_stripe = "Wheat",
table_stub_background = "Tan",
table_stub_font_color = "White")
# Create table object
tbl <- create_table(dat, borders = "all") %>%
titles("MTCARS Dataset With Style") %>%
column_defaults(width = .5) %>%
define(stub, label = "Car Make and Model", width = 1.5)
# Create report and add style spec
rpt <- create_report(tmp, output_type = "HTML") %>%
add_content(tbl) %>%
add_style(style = sty)
# Write out the report
write_report(rpt)
# Uncomment to View report
# file.show(tmp)
Run the code above in your browser using DataLab