74

I want to print a long string to the RStudio console so that it does not get truncated.

> paste(1:300, letters, collapse=" ")
[1] "1 a 2 b 3 c 4 d 5 e 6 f 7 g 8 h 9 i 
...
181 y 182 z 183 a 184 b... <truncated>

I supposed this should be fairly simple, but I cannot figure out how. I tried

options(max.print = 10000)

and looked through the args on the print help pages. Still no luck.

What parameter / settings to I have to change to achieve this?

smci
  • 32,567
  • 20
  • 113
  • 146
Mark Heckmann
  • 10,943
  • 4
  • 56
  • 88
  • It won't be on the `print` help pages I guess because it is not from R, but from Rstudio. No truncation happens in R console for your example. – Frank Apr 22 '16 at 18:02
  • 2
    FWIW, the output of that call to `paste()` is not truncated for me in RStudio 0.99.486 (which is likely fairly out of date). – Josh O'Brien Apr 22 '16 at 18:12
  • Same for me. No trucation in RStudio 0.99.896, even if I change 300 to 10,000 in the OP's code. – eipi10 Apr 22 '16 at 18:15
  • 1
    Ah okay. I use the preview Version 0.99.1130. So maybe its a new feature... – Mark Heckmann Apr 22 '16 at 21:06

1 Answers1

115

This is an RStudio-specific feature, intended to help resolve problems where printing overly long strings could cause IDE sluggishness. (I believe it was added with the latest release, v0.99.896)

You can opt-out of this truncation by setting the Limit length of lines displayed in the console to: option to 0 (see the final option in the dialog):

enter image description here

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88
  • 2
    This option is not available in my Rstudio, I'm using version 0.99.903, here is the [snapshot](https://i.stack.imgur.com/uMhvl.png), can you help if you have any code or other way to do this, Thank you! – subro Jun 26 '17 at 12:31
  • 1
    The answer above is correct on RStudio. In order to get to the screen referenced above, in the RStudio tabs above the IDE, select `Tools --> Global Options...`, and then follow the recommended steps. Remember these are global options, so please use with caution, for large output, this can significantly slow down the IDE performance (sometimes it can freeze). – Marquistador Nov 21 '17 at 16:12
  • 2
    Yes. But 0 (infinite console history) can slow you down and blow up your memory usage if you accidentally ever print an entire dataframe, e.g. due to a typo. Better to pick a large value e.g. 100,000. – smci May 19 '18 at 02:19
  • 1
    6 years later and still no solution. – Faindirnomainzein Apr 20 '22 at 13:15