Skip to content

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

2 messages · Roger D. Peng, Brian Ripley

#
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
#
On Thu, 27 Apr 2006, Roger D. Peng wrote:

            
So was I, as R-devel works in the same way as 2.2.1.  A simpler version is

rbind(x = data.frame(a = 1, b = 2), y = data.frame(a = 1, b = 2))

The problem is in the fix supplied for PR#8506, which happens to work in 
some cases and not others.  I've re-fixed it in 2.3.0 patched.