sebastien.villemot at ens.fr
2007-Sep-18 16:37 UTC
[Rd] rbind.data.frame converts character column to factor (PR#9917)
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