When preparing reports using rmarkdown: http://rmarkdown.rstudio.com/ one may want the document to render differently depending upon the document type. For ins
Yes, you can access the output format via knitr::opts_knit$get("rmarkdown.pandoc.to"). This will return a string with the target output format. Here's an example:
---
title: "Untitled"
output: html_document
---
```{r}
library(knitr)
opts_knit$get("rmarkdown.pandoc.to")
```
This returns "html" for html_document, "docx" for word_document, and "latex" for pdf_document. So to answer your question you can do something like:
html <- knitr::opts_knit$get("rmarkdown.pandoc.to") == "html"