user101089
user101089

Reputation: 3992

stitch/ Rstudio Compile notebook: modify default fig width, height?

In RStudio, the Compile notebook feature is very handy, but I'd like to be able to change the default figure width and height globally for a given .R script. How can this be done?

Upvotes: 2

Views: 1007

Answers (1)

Yihui Xie
Yihui Xie

Reputation: 30124

According to RStudio documentation, there are two possible notebook types at the moment. To achieve what you want, you have to choose the type knitr::spin, which allows you to change chunk options; see knitr documentation for details.

In this case, you just add a code chunk to set up chunk options, e.g.,

#+ setup, include=FALSE
library(knitr)
opts_chunk$set(fig.width = 5, fig.height = 10)

#' write the rest of your code
1 + 1
rnorm(10)
plot(cars)

knitr spin

Upvotes: 4

Related Questions