I\'m pretty much a beginner at programmatically formatting R output, but I\'ve got a basic understanding of knitr
, xtable
, Markdown, and Pandoc\'s
Here is a solution using ReporteRs
:
set.seed(123)
df <- data.frame(id = sample(1:100, 20, replace = TRUE),
inputval = sample(seq(0, 1, by=0.01), 20, replace = TRUE),
outcome = sample(1:4, 20, replace = TRUE))
library( ReporteRs )
library( magrittr )
# create and format table
myft = df %>% FlexTable() %>%
setRowsColors( df$outcome == 1, 'magenta') %>%
setFlexTableWidths( c( 1, 1, 1) )
# create an html doc and send myft into
doc = bsdoc() %>% addFlexTable( myft )
# write the html file in a new dir
writeDoc( doc, "example_out/df.html")