Search code examples
rconsoleoutputrstudio

How to increase amount of output retained by R console


I'm struggling with how much output is retained in RStudio's console. An MWE would be:

for(i in 1:2000){print(i)}

Of the 2,000 printed iterations, only 1,000 lines are retained in the RStudio console. In other words, scrolling up all the way to the top of the RStudio console, the output is truncated at a printed i of 1001.

To emphasize: these are separate instances of printing to the console, so this has nothing to do with the "max.print" option (which we set to options(max.print=100000) anyway). This is solely about the number of lines retained by RStudio's console, or put differently, the absolute "height" of the console.

This is not an issue when running R through a terminal.

Is someone aware of an RStudio option to increase the amount of lines retained in its console? The RStudio options "Limit output line length" and "Limit visible console output" in Tools > Global Options > Console do not influence this behavior.

Thanks and best, Chris


Solution

  • you can use rstudioapi::writeRStudioPreference("console_max_lines", <<Number of Lines>>). <<Number of Lines>> needs to be and Integer so 2000L not 2000. Then restart RStudio and it will be updated. Be cautious though, this can slow down RStudio a lot for large values.