markdown - Color print R mark down html -
i wonder there way force web browser print r mark down html in colors. can achieved editing bootstrap file wonder if done within markdown file.
reproducible example:
test.rmd
--- title: "habits" output: html_document --- ```{r, echo = false} df <- data.frame( id = 1:10, name = c("bob", "ashley", "james", "david", "jenny", "hans", "leo", "john", "emily", "lee"), age = c(28, 27, 30, 28, 29, 29, 27, 27, 31, 30), grade = c("c", "a", "a", "c", "b", "b", "b", "a", "c", "c"), test1_score = c(8.9, 9.5, 9.6, 8.9, 9.1, 9.3, 9.3, 9.9, 8.5, 8.6), test2_score = c(9.1, 9.1, 9.2, 9.1, 8.9, 8.5, 9.2, 9.3, 9.1, 8.8), final_score = c(9, 9.3, 9.4, 9, 9, 8.9, 9.25, 9.6, 8.8, 8.7), registered = c(true, false, true, false, true, true, true, false, false, false), stringsasfactors = false) ``` ``` {r, eval = true, echo = false, results='asis'} library(formattable) format_table(df, list( age = color_tile("white", "orange"), grade = formatter("span", style = x ~ ifelse(x == "a", style(color = "green", font.weight = "bold"), na)), final_score = formatter("span", style = x ~ style(color = ifelse(rank(-x) <= 3, "green", "gray")), x ~ sprintf("%.2f (rank: %02d)", x, rank(-x))), registered = formatter("span", style = x ~ style(color = ifelse(x, "green", "red")), x ~ icontext(ifelse(x, "ok", "remove"), ifelse(x, "yes", "no"))) )) ```
this browser option mentioned [https://stackoverflow.com/users/4497050/alistaire]. best way color print save html page shinyapp pdf , print pdf.
Comments
Post a Comment