ripley at stats.ox.ac.uk
2007-Sep-21 13:11 UTC
[Rd] (PR#9917) rbind.data.frame converts character column to
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--27464147-159404577-1190380210=:1425
Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT
Please do read the documentation, which says
The 'rbind' data frame method first drops all zero-column and
zero-row arguments.
So your first data frame has been dropped, and the result is the same as
rbind.data.frame(list(a = "foo")) which should give a factor column
via
promotion of a list to a data frame.
On Tue, 18 Sep 2007, sebastien.villemot at ens.fr wrote:
> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
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
--27464147-159404577-1190380210=:1425--
Possibly Parallel Threads
- [Bug 46779] New: Freeze on G86 [Quadro NVS 290] under Gnome Shell when opening Firefox tabs
- Variables ordering problem in mle() (PR#9313)
- c(), rbind and cbind functions - why type of resulting object is double
- Sweave issue: quotes in verbatim-like output print incorrectly
- Processed (with 2 errors): notfound 706747 in 3.2p1.4-28.1, tagging 706747, fixed 676134 in 3.8.5-2, found 725433 in 2.0.19-2 ...
