How to make options(width = 60) persist across code chunks in R Markdown used as notebook in RStudio?

I have an R Markdown file that I want to use as a notebook inside RStudio by interactively executing individual (!) code chunks and seeing their results, e.g., prints, tables, plots, displayed under the code chunk. In particular, I am not interested in knitting the entire R Markdown file at this point. The .Rmd file contains nothing but the following code chunks A, B, and C.

```{r A}
options("width")    # => 96 on my system
```

```{r B}
options(width = 60)
options("width")    # => 60
```

```{r C}
options("width")    # => 96 but I expected 60
```

When I open a fresh instance of RStudio, open the .Rmd file, clear the knitr cache using RStudio's "Clear Knitr Cache..." Knit-menu item, and run the chunks, one by one, in the listed order using RStudio's chunk-specific "Run Current Chunk" buttons, I get 96, the default width on my system, for chunk A, 60 for chunk B, and 96 for chunk C.

Why does the new global width set in chunk B not persist into chunk C?

I am using RStudio version 1.4.1717 with rmarkdown version 2.10 and knitr version 1.34 on macOS Catalina.

A similar question about options(digits = N) was asked here and the single answer was accepted by the asker. However, the example given in the answer fails to demonstrate persistence of R's global options across chunks as the relevant code chunks include their own options(digits = ...) calls. When I tested the example from that answer on my system using an additional code chunk without options(digits = ...) call, the "digits" value set in the previous chunk did not persist.


This only happens when using the document as a Notebook in RStudio. If you knit the whole document, you should see the expected behaviour.

I suspect the reason is that RStudio sets the option depending on the size of your edit window. I don't see any option in it that would let you change this behaviour, but you might be able to find one if you look at the .rs.rnb.* objects in the tools:rstudio environment. That's initially loaded in position 2 in the search() list.