When preparing reports using rmarkdown
: http://rmarkdown.rstudio.com/ one may want the document to render differently depending upon the document type. For instance I may want to embed a youtube video if the document being rendered is an html file where as if it's pdf or MS Word I would want the hyper-linked URL instead.
Is there a way to tell rmarkdown
something like this:
if (html) {
<iframe width="640" height="390" src="https://www.youtube.com/embed/FnblmZdTbYs? feature=player_detailpage" frameborder="0" allowfullscreen></iframe>
} else {
https://www.youtube.com/watch?v=ekBJgsfKnlw
}
code
devtools::install_github("rstudio/rmarkdown")
library(rmarkdown)
render("foo.Rmd", "all")
foo.Rmd
---
title: "For Fun"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
html_document:
toc: true
theme: journal
number_sections: true
pdf_document:
toc: true
number_sections: true
word_document:
fig_width: 5
fig_height: 5
fig_caption: true
---
## Good times
<iframe width="640" height="390" src="https://www.youtube.com/embed/FnblmZdTbYs?feature=player_detailpage" frameborder="0" allowfullscreen></iframe>