Skip to content

Instantly share code, notes, and snippets.

@njtierney
Created March 9, 2015 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njtierney/7134f9899fa1c1263147 to your computer and use it in GitHub Desktop.
Save njtierney/7134f9899fa1c1263147 to your computer and use it in GitHub Desktop.
This code is my standard setup for rmarkdown in knitr.
```{r global_options, include=FALSE, cache=FALSE}
library(knitr)
# Set basic options. You usually do not want your code, messages, warnings etc.
# to show in your actual manuscript however for the first run or two these will
# be set on.
opts_chunk$set(echo=FALSE,
warning=FALSE,
message=FALSE,
cache = TRUE,
include = FALSE,
results = 'hide',
error = TRUE)
# setup changes according to html or docx
output <- opts_knit$get("rmarkdown.pandoc.to")
if (output=="html") {
opts_chunk$set(fig.width=11,
fig.height=11)
} # # end html `if` statement
## setting up the figure parameters for docx
if (output=="docx") {
opts_chunk$set(dev = 'pdf',
fig.width = 6,
fig.height = 6)
} # end docx `if` statement
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment