[R] bug & paste (continues...)

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Oct 9 18:27:20 CEST 2001


Ott Toomet <siim at obs.ee> writes:

> > e1 <- e0
> > paste( e1, m, sep="")
> [1] "9<1>"  "2<2>"  "2<3>"  "1<4>"  "A"     "1<6>"  ""      "NA<8>" "5END"
> 
> but it vanishes when you save and load data:
> > save( e0, file="jama.rd")
> > load( "jama.rd")
> > paste( e0, m, sep="")
> [1] "9<1>"  "2<2>"  "2<3>"  "1<4>"  "A<5>"  "1<6>"  "<7>"   "NA<8>" "5END"
> 
> 
> If you have any more ideas...

Maybe. If you set sep=";", it won't show for 5&7 either, right?

Inside paste.c, we have 

        buf += LENGTH(STRING_ELT(VECTOR_ELT(x, j), i % k));

which reads the string length out of the SEXP field for the string. If
this is out of sync with the actual length of the string, the things
you describe could easily happen. 

Not really sure whether to put this down to non-defensive programming
in paste() or a bug in read.dta()... Probably mostly the latter.
 
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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