p.dalgaard@biostat.ku.dk
1999-Sep-05 22:00 UTC
[R] data frame component replacement: feature or bug? (PR#266)
Matthew Wiener <mcw@ln.nimh.nih.gov> writes:> t1 <- data.frame(matrix(rnorm(16), nc=4)) > t1$X1 <- 1 > t1$X2 <- 2 > print(t1) > Error: dim<- length of dims do not match the length of objectWell, it is prototype-compatible. Splus 5.3 does likewise. A way out is t1<-data.frame(unclass(t1)) However, we do seem to have a bug in the area:> t1 <- data.frame(matrix(rnorm(16), nc=4)) > transform(t1,X1=1)Error: dim<- length of dims do not match the length of object> transform(t1,X1=1,X2=2)X1 X2 X3 X4 1 1 2 0.6020524 1.1595935 2 1 2 -1.8212204 -0.2118746 3 1 2 1.5506706 0.0680275 4 1 2 -0.8872958 0.4709870 This boils down to the construction dfr[1]<-list(X1=1) which doesn't extend dfr$X1, whereas dfr[c(1,2)]<-list(X1=3,X2=4) does. Splus handles both cases. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
1999-Sep-05 22:32 UTC
[R] data frame component replacement: feature or bug? (PR#266)
p.dalgaard at biostat.ku.dk writes:> dfr[1]<-list(X1=1) > > which doesn't extend dfr$X1, whereas > > dfr[c(1,2)]<-list(X1=3,X2=4) > > does. Splus handles both cases.Found, fixed, and committed for 0.65.1 (a drop=FALSE was missing where the replication was done) -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._