Last active
June 3, 2019 13:27
-
-
Save njtierney/d5a877a6dc8a97f2b4a5 to your computer and use it in GitHub Desktop.
This chunk is what I usually write at the start of most rmarkdown documents.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{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
The second part is really nifty.
It basically means that I can set different image heights, and other settings, depending on whether I decide to knit the document into
html
ordocx
formats. You could also include one forpdf
if you wanted by mimicking the code.