[Rd] (PR#9578) rbind.data.frame reacts on levels without

ripley at stats.ox.ac.uk ripley at stats.ox.ac.uk
Thu Mar 29 12:59:19 CEST 2007


In your data frames, 'y' is a category and the following comment in the
code makes clear this is deliberate.

 		    if( !is.null(levels(xj)) ) {
 			all.levs[[j]] <- levels(xj)
                         facCol[j] <- TRUE # turn categories into factors
                     } else facCol[j] <- is.factor(xj)

The behaviour is compatible with S apart from the comment in the R help 
page.  That categories are promoted to factors is consistent with the help 
for 'category'.

It is not a bug, but the help page could say what happens for categories.

On Fri, 23 Mar 2007, Lutz Prechelt wrote:

> I am sorry.
> Here is a minimal example:
>
> a=data.frame(x=c(1:3),y=unclass(factor(c(5:7))))
> b=data.frame(x=c(11:13),y=unclass(factor(c(7:9))))
> rbind(a,b)
>
>  Lutz Prechelt
>
>

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