[R] RW 0.64.2 substring() string truncation?

T.E.Diaz tediaz at gwis2.circ.gwu.edu
Tue Aug 3 05:06:20 CEST 1999


Hi,

(First, apology for my earlier incorrectly addressed "subscribe" 
post.)

Can somebody tell me what exactly is going on below. Basically, I am 
running into some kind of "string truncation" problem when I try 
to get a substring starting past the 8192nd character (see sample 
session below). There doesn't appear to be any problem creating the 
string, and nchar() reports the correct size as constructed.

# Start of R session:
>  tmp <- paste(rep("1",8192),sep="",collapse="")
> nchar(tmp)
[1] 8192
> tmp <- paste(tmp,"23456789",sep="",collapse="")
> nchar(tmp)
[1] 8200
> substring(tmp,8190,8192)
[1] "111"
> substring(tmp,8190,8193)
Warning in substr(x, as.integer(start), as.integer(stop)) : a string was truncated in substr()
[1] "111"
>
# End of R session:

Thanks for any assistance.

T.E.Diaz
George Washington University
Washington, DC

For comparison, I run the following in Splus 4.0.

# Start of Splus 4.0 session.
> tmp <- paste(rep("1",8192),sep="",collapse="")
> nchar(tmp)
[1] 8192
> 
> tmp <- paste(tmp,"23456789",sep="",collapse="")
> nchar(tmp)
[1] 8200
> substring(tmp,8190,8192)
[1] "111"
> substring(tmp,8190,8193)
# End of Splus 4.0 session.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list