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

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Apr 28 10:22:01 CEST 2006


On Thu, 27 Apr 2006, Roger D. Peng wrote:

> 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

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.

>
> > ## 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
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list