From sebastien.villemot at ens.fr  Tue Sep 18 18:37:44 2007
From: sebastien.villemot at ens.fr (sebastien.villemot at ens.fr)
Date: Tue, 18 Sep 2007 18:37:44 +0200 (CEST)
Subject: [Rd] rbind.data.frame converts character column to factor (PR#9917)
Message-ID: <20070918163744.CED7F66835@slim.kubism.ku.dk>

Full_Name: S?bastien Villemot
Version: 2.5.1
OS: Debian GNU/Linux (Testing aka "Lenny")
Submission from: (NULL) (193.51.127.120)


Here is the transcript of a R session under version 2.5.1:

> x <- data.frame(a = I(character(0)))
> typeof(x$a)
[1] "character"
> x <- rbind(x, list(a = "foo"))
> typeof(x$a)
[1] "integer"

The column "a" has been converted from character to factor.

This was not happening under version 2.4.0 Patched (2006-11-25 r39997):
> x <- data.frame(a = I(character(0)))
> typeof(x$a)
[1] "character"
> x <- rbind(x, list(a = "foo"))
> typeof(x$a)
[1] "character"

Furthermore, the bug doesn't show up (in 2.5.1) if the data frame is initially
non-empty:
> x <- data.frame(a = I("bar"))
> typeof(x$a)
[1] "character"
> x <- rbind(x, list(a = "foo"))
> typeof(x$a)
[1] "character"

Best,

S?bastien Villemot



[Rd] rbind.data.frame converts character column to factor (PR#9917)
sebastien.villemot at ens.fr