[R] Why does substr<- truncate and not replace...
tov at ece.cmu.edu
Fri Sep 7 22:02:52 CEST 2001
... when the replacement string is shorter than the portion of the
string to be replaced?
The documentation to substr (in R 1.3.1) gives me:
If the portion to be replaced is longer than the replacement
string, then only the portion the length of the string is
And so I try:
R> x <- "abcdef"
R> substr(x,2,3) <- "xy" #ok
R> substr(x,2,3) <- "w" #ko
hmm, I would have expected "awdef". Am I reading the docs wrong? (Or
am I just blinded to expect this string because that's what Perl would do?)
mailto:tov at ece.cmu.edu (Tom Vogels) Tel: (412) 268-6638 FAX: -3204
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