From cgenolin at u-paris10.fr  Sun Oct 26 19:35:09 2008
From: cgenolin at u-paris10.fr (cgenolin at u-paris10.fr)
Date: Sun, 26 Oct 2008 19:35:09 +0100
Subject: [Rd] unlist change the ordered type
In-Reply-To: <Pine.LNX.4.64.0810242153130.21259@tajo.ucsd.edu>
References: <49023ADF.2070003@u-paris10.fr>
	<Pine.LNX.4.64.0810242153130.21259@tajo.ucsd.edu>
Message-ID: <20081026193509.dnzy98n40004k4oc@icare.u-paris10.fr>

"Charles C. Berry" <cberry at tajo.ucsd.edu> a ??crit??:

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

This "only special" case is quite common since the use of lapply on 
ordered gives such a list

Christophe



[Rd] unlist change the ordered type
cgenolin at u-paris10.fr