How to keep more than 1000 lines of output in RStudio console

I have the same question as More than 1000 lines of output in R Studio and [Displaying more than 1000 lines in the R Studio console?](https://Displaying more than 1000 lines in the R Studio console?).

Rather than examining thousands of lines of output by eye, I'd like to refer to the output of earlier commands, sometimes after displaying something large by accident or by running something which logs enough lines to fill the 1000-line buffer.

I took @jonathan 's advice (in the replies to the first link above) about using rstudioapi::writeRStudioPreferences("console_max_lines", 300)
but wasn't immediately satisfied. You can also do it within the IDE: Tools / Global Options / Code / Display / Limit length of lines displayed in console to:.

I did figure it out, so here's what I found:

  • First, the original advice suggested 300, but you wouldn't be reading this if you didn't want more. Use 3000L or a larger number, but it needs the 'L' or as.integer() to make it an integer (see this post from @EvelynK
  • Second, You need to restart RStudio for it to take effect
  • Third, if you really are showing something large, then you'll also need options(max.print=10000) or some other suitably large number.

My laptop is happily scrolling 3000 lines with RStudio 1.3.959, the fears about poor performance seem unfounded in the modern age.

Happy scrolling!

2 Likes

Not all heroes wear capes.

I this seems like a definitive answer to a problem that a not trivial number of us have had. Let's hope it continues to work, or becomes a core feature with a larger default (as it probably should be!)

Thankyou again :slight_smile: