Re: [Rd] (PR#9917) rbind.data.frame converts character column to

From: <ripley_at_stats.ox.ac.uk>
Date: Fri, 21 Sep 2007 15:11:29 +0200 (CEST)


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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 21 Sep 2007 - 13:15:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 22 Sep 2007 - 12:41:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.