When preparing reports using rmarkdown
: http://rmarkdown.rstudio.com/ one may want the document to render differently depending upon the document type. For ins
As pointed out in an answer to a related question, knitr
1.18 introduced the following functions
knitr::is_html_output()
knitr::is_latex_output()
As the name suggests, is_html_output()
checks if the output is HTML. You would add something like this to foo.Rmd
:
```{r results='asis'}
if (knitr::is_html_output()) {
cat('')
} else {
cat("https://www.youtube.com/watch?v=ekBJgsfKnlw")
}
```