Skip to content
Prev 392192 / 398502 Next

Does the function "c" have a character limit?

Hello,

This is documented behavior.
 From R-intro, last line of section 1.8 [1].


Command lines entered at the console are limited4 to about 4095 bytes 
(not characters).


The number 4 in limited4 is a footnote link:


some of the consoles will not allow you to enter more, and amongst those 
which do some will silently discard the excess and some will use it as 
the start of the next line.



Prof. Ripley called the r-devel mailing list's attention to this in 
August 2006 when the limit was 1024 [2], it was then increased to the 
current 4095. I remember seeing a limit of 2048 (?) but couldn't find where.


Try creating a file with your command as only content, then run


x <- readLines("rhelp.txt")
nchar(x)
# [1] 4096


You are above the limit by 1 byte.
Standard solutions are to break the command line, in your case into at 
least 2 lines, or to source the command from file, like David proposed.


[1] 
https://cran.r-project.org/doc/manuals/R-intro.html#R-commands_003b-case-sensitivity-etc
[2] https://stat.ethz.ch/pipermail/r-devel/2006-August/038985.html


Hope this helps,

Rui Barradas


?s 00:36 de 13/07/2022, core_contingency escreveu: