Avoid String Printed to Console Getting Truncated (In Rstudio)

avoid string printed to console getting truncated (in RStudio)

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):

Sample Image

print entire string to console without truncating and without adjusting a global setting

The short answer is "no" since, the option limiting the print is in the IDE itself, which you can't control from your program itself (I'm assuming you're not some crazy hacker here), and not a language feature. It's like trying to stop "WINDOWS" from doing things (although not).

Seems to me the easiest way (ad hoc) is to turn it on, do whatever, then turn it off. If you insist on not doing that, you need to write your own function:

myprint<- function(somestring,idelimit=100) {
for(i in seq(1,nchar(somestring),idelimit+1)) {

I'm not a fluent R coder so let me know if you catch a syntax error. The idea is simple - idelimit should be wherever studio truncates (I chose 100 arbitrarily), and basically you're doing the splitting yourself so string is printed line after line without truncation. Each time you take a portion at most idelimit long from somestring and print it.

list output truncated - How to expand listed variables with str() in R

You can use the argument list.len:

str(df, list.len=ncol(df))

and if you want to print more observations you could set the argument vec.len, also have a look at ?str for documentation of all arguments.

Related Topics

Leave a reply