[R] more on paste and bug
tlumley at u.washington.edu
Wed Oct 10 21:45:18 CEST 2001
On 10 Oct 2001, Saikat DebRoy wrote:
> As it happens, I think the problem is in the read.dta code. The relevant
> piece of code is in foreign/src/stataread.c (lines 317-324):
> As it happens, in this case the string "A" is written in the file
> as two bytes (I do not not know why) with the second byte being '\0'.
> So the above code creates a CHARSXP of length 3 with last two bytes
> being '\0'.
It happens because Stata treats strings as a fixed-length type, padded on
the right with nulls. I didn't realise that R would incorporate trailing
nulls into the string.
It's easily fixed by just reading into a buffer and using strlen before
It might be a bug that the LENGTH() of a string can be longer than its
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