0
votes

I'd like to add an interactive map (a leaflet) to my HTML document, but this can't be done in a PDF document since they are static.

I know that Rmarkdown can choose to evaluate a chunk depending on a global variable, like this:

```{r setup}
ev_cars = TRUE
```

## First chunk

```{r cars, eval=ev_cars}
summary(cars)
```

I guess my question is "does knitr set a global variable indicating whether it is knitting an html_document or a pdf_document" ?

thanks

1

1 Answers

0
votes

knitr::is_latex_output() and knitr::is_html_output do that job.

ref: https://bookdown.org/yihui/rmarkdown-cookbook/latex-html.html