probably you are looking for something like the following:

dat <- data.frame(chr = letters[1:20], x = rnorm(20), y = rnorm(20))
chr.vec <- sample(letters[1:20])
####################3
dat[match(chr.vec, dat$chr), ]


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Ken Termiso" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, January 23, 2006 4:55 PM
Subject: [R] ordering a data frame to same order as a chr vector


> Hi all,
>
> I've got a data frame that has an identical column to a chr vector. 
> I would
> like to use the chr vector to order the rows of the data frame to be
> identical to the order in the chr vector (the contents of the chr 
> vector are
> completely identical to one col of the data frame), but this is 
> proving
> trickier than it sounds..
>
> Any help would be much obliged,
> -Ken
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to