[R] Why the factor levels returned by cut() are not ordered?

Petr Pikal petr.pikal at precheza.cz
Wed Nov 29 10:26:35 CET 2006


Hi

it is not stated that the cut shall return ordered factor. If you 
want you can use

ordered(cut( breaks=3, sample(10 ) ))
or modify code for cut.default to accept ordered switch.

HTH
Petr




On 29 Nov 2006 at 9:59, Wolfram Fischer wrote:

Date sent:      	Wed, 29 Nov 2006 09:59:36 +0100
From:           	Wolfram Fischer <wolfram at fischer-zim.ch>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] Why the factor levels returned by cut() are not ordered?

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

Petr Pikal
petr.pikal at precheza.cz



More information about the R-help mailing list