On Dec 9, 2009, at 10:10 PM, Peng Yu wrote:

I did a search on www.rseek.org to look for the function to test if a
vector is ordered or not. But I don't find it. Could somebody let me
know what function I should use?


If by ordered, you mean sorted, then ?is.unsorted

> is.unsorted(c(1, 4, 2, 6, 7))
[1] TRUE

> is.unsorted(sort(c(1, 4, 2, 6, 7)))
[1] FALSE


If you mean to test a factor to see if it is an ordered factor, then ? is.ordered

> is.ordered(factor(letters))
[1] FALSE

> is.ordered(factor(letters, ordered = TRUE))
[1] TRUE


HTH,

Marc Schwartz

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

Reply via email to