[Rd] difference in rbind() [print?] behavior between 2.2.1 and 2.3.0

Roger D. Peng rpeng at jhsph.edu
Thu Apr 27 14:58:12 CEST 2006


I'm a little confused by a change in behavior from 2.2.1 to 2.3.0.  In 2.2.1 I 
could do

 > ## Create a list of data frames in 2.2.1
 > b <- list(x = data.frame(a = 1, b = 2), y = data.frame(a = 1, b = 2))
 > do.call("rbind", b)
   a b
x 1 2
y 1 2

But in 2.3.0 I get

 > do.call("rbind", b)
Error in data.frame(a = c("1", "1"), b = c("2", "2"), check.names = FALSE,  :
         row names contain missing values

Traceback indicates that the error is actually in the print method.

 > d <- do.call("rbind", b)
 > d
Error in data.frame(a = c("1", "1"), b = c("2", "2"), check.names = FALSE,  :
         row names contain missing values

But:

 > d[1:2, ]
     a b
NA  1 2
NA1 1 2
 >

I'm not sure those are the intended row names but I'm not sure.  The following 
does seem to work as I would have expected:

 > b <- list(x = data.frame(a = 1:2, b = 2:3), y = data.frame(a = 1:2, b = 2:3)) 
 > do.call("rbind", b)
     a b
x.1 1 2
x.2 2 3
y.1 1 2
y.2 2 3
 >


-roger
-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/



More information about the R-devel mailing list