Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

avoid string printed to console getting truncated (in RStudio)

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?

like image 426
Mark Heckmann Avatar asked Apr 22 '16 17:04

Mark Heckmann


People also ask

How do you print text in R console?

To display ( or print) a text with R, use either the R-command cat() or print(). Note that in each case, the text is considered by R as a script, so it should be in quotes. Note there is subtle difference between the two commands so type on your prompt help(cat) and help(print) to see the difference.

How do I print a string and output in R?

R provides a method paste() to print output with string and variable together. This method defined inside the print() function. paste() converts its arguments to character strings. One can also use paste0() method.

What is truncated in R?

September 9, 2021 February 4, 2021 by Krunal Lathiya. The trunc() method in R is truncate, which rounds to the nearest integer in the direction of 0. The trunc() function truncates the values in the decimal places.


1 Answers

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

like image 135
Kevin Ushey Avatar answered Sep 23 '22 17:09

Kevin Ushey