Yes,

x[order(order(z)),]


Two uses of order are needed, as shown.


Rich


On Sun, Aug 15, 2010 at 11:47 PM, Leon Yee <yee.l...@gmail.com> wrote:

> Dear all,
>
>     I have a data frame with several columns, and I have the specified
> order of a given column. How can I re-order the rows of my data frame
> accroding to this specified order? for example,
>
> x = data.frame( num = 1:26, alpha = letters[1:26], stringsAsFactors=FALSE)
> z = sample(x$alpha, replace=FALSE)
>    Can I re-order x accroding to z ?
>
>    Thanks,
>
> Leon
>
>

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