[R] match rows of data frame

Alfonso Sammassimo cincinattikid at bigpond.com
Fri Jun 8 02:42:08 CEST 2007


Hi R-experts,

I have a data frame (A) , and a subset (B) of this data frame. I am trying 
to create a new data frame which gives me all the rows of B, plus the 5th 
next row(occuring in A).  I have used the below code, but it gives me all 5 
rows after the matching row. I only want the 5th.

FiveDaysLater <- A[c(sapply(match(rownames(B),rownames(A)), seq, 
length=6))),]

Any guidance much appreciated,
Thankyou.

Alfonso Sammassimo
Melbourne, Australia.



More information about the R-help mailing list