Hello people.

I wish to reorder a simple vector of numbers by another vector of the order
(and then do the same, but with a data frame rows)

I try this (which doesn't work) :
> aa <- c(3, 1 ,2 )
> aa[aa]
[1] 2 3 1

The same won't work if I try to order a data frame:
> data.frame(matrix(c(3,1,2), 3,2))[c(3,1,2),]
  X1 X2
3  2  2
1  3  3
2  1  1


How should I do this?


p.s: sorry if the question is too simple, but I couldn't find a good
explanation for this on google.
p.p.s: I am running R 2.8


Thanks,
Tal

        [[alternative HTML version deleted]]

______________________________________________
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