I have an Rmd script that includes some visualizations. When I run each chunk one by one during development I see the visuals display as expected in Rstudio.
But when I select knit > render as html, the analysis generates an html doc but the visuals are missing.
I tried running the example Rmd file that's generated when one selects to create a new Rmd file, the one with a summary of mtcars and plot(pressure). When I render this doc as html the visuals do render in the resulting html doc.
I'm convinced this is to do with the chunk options I have set. Here is what I have, any pointers or guidance most welcome.
(Note the backslash '' in front of the ticks ` below are not actually in my script, they are there just to get the example blocks to render as close to correct as I can get.)
\```{r setup, include=FALSE}
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
include = FALSE
)
pacman::p_load(tidyverse, CLVTools, lubridate, glue, Metrics)
\```
Block with a visual that shows no visual when rendering as html:
\```{r analysis, echo=TRUE, message=FALSE, warning=FALSE}
analysis %>% pivot_wider(names_from = c(func, cut_off), values_from = mae_trans:auc, names_sep = " ") %>% DT::datatable()
\```
Another one:
\```{r visualization, echo=TRUE, message=FALSE, warning=FALSE}
metrics <- analysis %>% select(mae_trans:auc) %>% names
metrics %>% map(~ ggplot(analysis, aes(x = MONETIZATION_WEEK_COHORT, y = get(.x), color = func)) + geom_line() + ylab(.x))
\```
Why do the DT::datatable and ggplot visuals show when running a chunk individually but not when I render the doc as html as a whole?