[R] Partial sort?
andrew
andrewjohnroyal at gmail.com
Thu Jan 15 01:07:43 CET 2009
I had a similar misunderstanding of using partial in sort() a while
back when I was trying to sort by columns, a la Excel. In this case,
I ended up using the order() function, eg:
require(stats)
swiss[order(rownames(swiss)), ] #sort by location
swiss[order(swiss$fertility), ] #sort by fertility
Not sure if this helps, as I am attempting to do a mind read based on
ASCII (I get better results using unicode)
Regards,
Andrew
On Jan 15, 10:42 am, Duncan Murdoch <murd... at stats.uwo.ca> wrote:
> rkevinbur... at charter.net wrote:
> > This is definitely a newbie question but from the documentation I have not been able to figure out what the partial sort option on the sort method does. I have read and re-read the documentation and looked at the examples but for some reason it doesn't register. Would someone attempt to explain what sort with a non-null partial array of indices does?
>
> It guarantees that those particular indices are sorted correctly, but
> doesn't guarantee anything else. For example,
>
> > x <- 10:1
> > sort(x, partial=1)
>
> guarantees that the first entry in x (i.e. 10) is placed correctly, but
> nothing else, and the result is:
>
> [1] 1 9 8 7 6 5 4 3 2 10
>
> Duncan Murdoch
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list