On Apr 18, 2010, at 7:55 AM, David Winsemius wrote:
On Apr 18, 2010, at 6:03 AM, David.Epstein wrote:
Given an ordered factor, how does one unorder it?
I tried various commands with reorder, with order=F, but they all
gave me
error messages. I also tried to drop the order with various 'as dot
something' commands, but these didn't work either.
> ord <- ordered(4:1)
> str(ord)
Ord.factor w/ 4 levels "1"<"2"<"3"<"4": 4 3 2 1
> unclass(ord)
[1] 4 3 2 1
attr(,"levels")
[1] "1" "2" "3" "4"
> factor(unclass(ord))
[1] 4 3 2 1
Levels: 1 2 3 4
> is.ordered(factor(unclass(ord)))
[1] FALSE
So this appears to be the way --->
> ord <- factor(unclass(ord))
>
> str(ord)
Factor w/ 4 levels "1","2","3","4": 4 3 2 1
the class()<- operation also works:
> ord <- ordered(4:1)
> class(ord) <-"factor"
> ord
[1] 4 3 2 1
Levels: 1 2 3 4
> is.ordered(ord)
[1] FALSE
--
View this message in context:
http://n4.nabble.com/unorder-an-ordered-factor-tp2014745p2014745.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@r-project.org 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.
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org 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.
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org 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.