You can also write
x[match(z,x[,2]),].
Leila
on 2010/08/16 06:36 AM RICHARD M. HEIBERGER said the following:
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 wrote:
Dear all,
I have a data frame with several columns,
>
> Yes,
>
> x[order(order(z)),]
>
> Two uses of order are needed, as shown.
>
Thank you very much, Rich. It's like a magic!
Leon
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r
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 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
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, re
4 matches
Mail list logo