Re: [Rd] unlist change the ordered type

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Fri, 24 Oct 2008 22:09:40 -0700

On Fri, 24 Oct 2008, Christophe Genolini wrote:

> Hi the list,
>
> unlist respect the all the atomic type except orderd (it change of ordered
> into factor) :
>
> ### integer
> class(unlist(list(1:5,1:3)))
> #[1] "integer"
>
> ### numeric
> class(unlist(list(1.2,3.5)))
> #[1] "numeric"
>
> ### character
> class(unlist(list("e","e")))
> #[1] "character"
>
> ### factor
> class(unlist(list(factor("e"),factor("e"))))
> #[1] "factor"
>
> ### ordered
> class(unlist(list(ordered("e"),ordered("e"))))
> #[1] "factor"

Consider

         unlist(list(ordered(1:2),ordered(letters[1:4])))

Since one cannot deduce what ordering should apply, the best that can be done is to demote all arguments to factors.

This is the general case. Only in the special case in which all list elements are of class 'ordered' and the levels attributes are the same would this be sensible.

HTH, Chuck

>
> Christophe
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry_at_tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 25 Oct 2008 - 05:11:44 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 Sun 26 Oct 2008 - 20:30:26 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.

list of date sections of archive