Variable in chunk options causes error in R notebook

According to section 11.1 of the R Markdown Cookbook, you can use variables from previous chunks as chunk options in R Markdown documents. The cookbook provides the following example:

output: html_document

my_width <- 7

```{r, fig.width=my_width}

Beautiful! ... when the output is an html document.

While the above works when output is set to html_document, it does not when the output is set as output: html_notebook in the front matter. That results in an RStudio error:

Error creating notebook: invalid quartz() device size. See line 9.

Why is there an error for html_notebook but not html_document?

Related questions on Posit Community

  • This unanswered question is about R Markdown documents rather than notebooks.
  • This question has me wondering whether chunk options are run before other code in R Notebooks. I would think that defining the variables in the setup chunk would solve this, but it does not.

Thanks for the report.

I think this would be an issue in RStudio IDE which handle the Notebook format. I believe this is covered by

and by

you should subscribed and add to those issue maybe.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.