13

There seems to be a limit on the size of the string used in message. The following only prints until number 1859 (Using R v3.1.3 on 64 bit Win7 machine)

message(paste(seq(1,2000),collapse = "-"))

while

cat(paste(seq(1,2000),collapse = "-"))

prints it all. Is this a bug?

Relund
  • 611
  • 3
  • 14
  • 4
    Using R 3.2.0 on a linux machine prints it all – akrun May 21 '15 at 10:49
  • 1
    reproducible on 3.1.2, 64-bit MacOS – Ben Bolker May 21 '15 at 12:01
  • I use message to print the log from C++ code run in a R package. Given a verbose option this can be quite large. – Relund May 21 '15 at 12:40
  • 6
    You can have your c++ code to the logging (but that would go to a different stream). But you should probably think about a 'message chopper' that parcels it out into several shorter chunks. Assuming 'unlimited' string length for logging is ... maybe too much. Remember 80 char limits? ;-) – Dirk Eddelbuettel May 21 '15 at 13:03
  • I mainly use the verbose option for debugging so implementing a 'message chopper' may be overkill. Anyway the current hack is just to use cat instead even though some say that message is more consistent. – Relund May 21 '15 at 14:31
  • @DirkEddelbuettel RJDBC query error message is a nice example of the utility of big messages. For big queries created by scripts, you can't see where is the error. I applied tryCatch to `cat` the error instead of `message` it, but IMHO it's very inelegant. – Murta Jan 02 '17 at 01:06
  • I am not sure if it is relevant but `message()` uses stderr, while `cat()` uses stdout. I can reproduce this with R 3.4.0 on Win10 – Kevin Jul 08 '17 at 04:21

1 Answers1

1

There's a good solution in this question:

avoid string printed to console getting truncated (in RStudio)

As it suggests, if you're using RStudio, just go to Global Options -> Code -> Display -> Limit length of lines displayed in the console to:

And change the value to zero. It works for me.

krishan
  • 1,141
  • 1
  • 12
  • 24