Re: [Rd] 'ordered' destroyed to 'factor'

2017-06-18 Thread Joris Meys
o an > optimum? I struggle to recognize the project I loved in 2000. > > > Gesendet: Freitag, 16. Juni 2017 um 18:31 Uhr > Von: "peter dalgaard" > An: "Robert McGehee" > Cc: "Jens Oehlschlägel" , " > r-devel@r-project.org" > Betreff:

Re: [Rd] 'ordered' destroyed to 'factor'

2017-06-18 Thread Jens Oehlschlägel
: Freitag, 16. Juni 2017 um 18:31 Uhr Von: "peter dalgaard" An: "Robert McGehee" Cc: "Jens Oehlschlägel" , "r-devel@r-project.org" Betreff: Re: [Rd] 'ordered' destroyed to 'factor' > On 16 Jun 2017, at 15:59 , Robert McGehee wrote: >

Re: [Rd] 'ordered' destroyed to 'factor'

2017-06-16 Thread peter dalgaard
> On 16 Jun 2017, at 15:59 , Robert McGehee wrote: > > For instance, what would you expect to get from unlist() if each element of > the list had different levels, or were both ordered, but in a different way, > or if some elements of the list were factors and others were ordered factors? >> u

Re: [Rd] 'ordered' destroyed to 'factor'

2017-06-16 Thread Joris Meys
This can be traced back to the following line in unlist(): structure(res, levels = lv, names = nm, class = "factor") The Details section of ?unlist states specifically how it treats factors, so this is documented and expected behaviour. This is also the appropriate behaviour. In your case one co

Re: [Rd] 'ordered' destroyed to 'factor'

2017-06-16 Thread Robert McGehee
ons, but I think it would be hard to point to any single function and say it is wrong or needs to be changed. My best advice, is to just be careful when combining or aggregating factors. --Robert -Original Message----- From: R-devel [mailto:r-devel-boun...@r-project.org] On Behalf Of "Jen

[Rd] 'ordered' destroyed to 'factor'

2017-06-16 Thread Jens Oehlschlägel
Dear all,   I don't know if you consider this a bug or feature, but it breaks reasonable code: 'unlist' and 'sapply' convert 'ordered' to 'factor' even if all levels are equal. Here is a simple example: o <- ordered(letters) o[[1]] lapply(o, min)[[1]]  # ordered factor unlist(lapply(o, m