[R] ordering a data frame to same order as a chr vector

Ken Termiso jerk_alert at hotmail.com
Mon Jan 23 17:09:58 CET 2006


Let me clarify the problem a bit further:

tv <- 1:11108

tdf <- data.frame(cbind(11108:1, 22216:11109))


In this example, what I would like to do is re-order the entire tdf data 
frame based on its first column (since the contents of tdf[,1] are identical 
to tv, just not necessarily in the same order in my problem, but here 
obviously the tdf data frame is already ordered the same as tv).

I would like to use the vector tv to give tdf the same exact order as tv, 
based on that first column of tdf which is identical to tv.

Thanks,
ken




More information about the R-help mailing list