[R] rearranging data frame rows

From: Bojanowski, M.J. (Michal) <M.J.Bojanowski_at_fss.uu.nl>
Date: Sat 24 Jun 2006 - 02:38:24 EST

Hi Fede,

How about using merge()? For example:

n <- letters[1:10]
d1 <- data.frame( n=n, x1=rnorm(10) )
d2 <- data.frame( n=sample(n), x2=rnorm(10)) d1

Is this what you had in mind?

HTH, Michal

Hi All,

I have two data frames. The first contains data about a number of individuals,
coded in the first column with a name, in an order I find convenient.

The second contains different data about the same indivduals, in a different
order. Both data frame have the individual names in the first column.

I need to reorder the second data frame so the rows are rearranged in the same
manner as the fist. How?

I cannot turn the individual names in a numeric vairable with as.numeric(data1[,1]), because the two data frames are subset of different data,
so the the factor levels are way off between the two. I think I need to actually
use the names as a index.




Michal Bojanowski
ICS / Utrecht University
Heidelberglaan 2; 3584 CS Utrecht
Room 1428

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 24 03:04:02 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 24 Jun 2006 - 04:12:22 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.