[R] Why the factor levels returned by cut() are not ordered?
Petr Pikal
petr.pikal at precheza.cz
Wed Nov 29 15:18:18 CET 2006
On 29 Nov 2006 at 12:08, Peter Dalgaard wrote:
Date sent: Wed, 29 Nov 2006 12:08:21 +0100
From: Peter Dalgaard <P.Dalgaard at biostat.ku.dk>
To: Wolfram Fischer <wolfram at fischer-zim.ch>
Copies to: r-help at stat.math.ethz.ch
Subject: Re: [R] Why the factor levels returned by cut() are not ordered?
> Wolfram Fischer wrote:
> > What is the reason, that the levels of the factor
> > returned by cut() are not marked as ordered levels?
> >
> >
> >> is.ordered( cut( breaks=3, sample(10 ) ) )
> >>
> > FALSE
> >
> >
> It would arguably be the Right Thing, but there would be complications
> in modeling, where ordered factors result in polynomial contrast
> coding. (This, in my opinion, is a design mistake inherited from S,
> but it's not easy to change at this stage.)
Well
what about to change cut.default
if (codes.only)
code
else factor(code, seq(labels), labels)
to
if (codes.only)
code
else factor(code, seq(labels), labels, ...)
which enables to use ordered switch
> is.ordered( cut( breaks=3, sample(10 ), ordered=T ) )
[1] TRUE
Without this the result is same as before (I believe :-)
Petr
>> help(factor) >> >
> ... > If 'ordered' is 'TRUE', the factor levels are assumed to
> be ordered. > ... > > Wolfram > >
> ______________________________________________ >
> R-help at stat.math.ethz.ch mailing list >
> https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the
> posting guide http://www.R-project.org/posting-guide.html > and
> provide commented, minimal, self-contained, reproducible code. >
>
>
> --
> O__ ---- Peter Dalgaard Řster Farimagsgade 5, Entr.B
> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45)
> 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45)
> 35327907
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.
Petr Pikal
petr.pikal at precheza.cz
More information about the R-help
mailing list