copying huge strings via clipboard?
On 3/4/22 08:45, Carl Witthoft wrote:
Hi, This is on Windows10 via the R gui? .? I, admittedly inadvisably, tried to create a new character object by first copying a 1-million character string (including lead and trail "'" chars) to the clipboard and then, in the console,
foo <-
and hitting "paste" What I found is that, around 5000 characters, a newline ( "\n") char showed up.? Is this something that the Windows Clipboard does, or something odd about pasting into a command in R?
I'm the wrong person to comment on Windows clipboard features. ISTR that there is a character limit for R command line input, at least in some or perhaps all R installations. Subject: [R] parsing -?input?buffer overflow <http://markmail.org/message/iyjlmfsb4kp63cyi> permalink <http://markmail.org/message/iyjlmfsb4kp63cyi> From: Prof Brian Ripley (rip... at stats.ox.ac.uk) Date: Jun 13, 2008 1:52:06 am List: org.r-project.r-help "R does have limits on the command line length (1024 bytes up to R-devel, 4096 bytes there). What happens if you exceed that depends on the interface you are using (and you have not told us). Beyond that, the parser has a limit of MAXELTSIZE (8192 bytes) on strings. I don't see any need for 'improvement' though: why are you entering very long strings as part of the R program? They are data, and e.g. readLines() and scan() have no limits on string length beyond those imposed by R's internals (2^31-1 bytes)." I think that info is still current since a search of the ../manuals/R-int page says: --- copied The|R_StringBuffer|structure needs to be initialized, for example by static R_StringBuffer ex_buff = {NULL, 0, MAXELTSIZE}; which uses a default size of|MAXELTSIZE = 8192|bytes.Most current uses have a static|R_StringBuffer|structure, which allows the (default-sized) buffer to be shared between calls to e.g.|grep|and even between functions: this will need to be changed if R ever allows concurrent evaluation threads. --- end copy
David
>
> Postscript:? using
>
> >>? bar <- readChar('thefile.txt',1e6)
>
> the import works perfectly.
>
>