0

I have two tables, rfs19.122 and TAIR10Func. I am trying to find all matches between a column of each, and append the matches to one of the original tables. I came up with the for loop below, but it is quite slow. Is there a faster way to accomplish this?

n <-nrow(rfs19.122)
matches <- matrix()
for (row in 1:n) {
    position<-grep(paste('^', rfs19.122$Gene[row], sep=''), TAIR10Func$Function)
    matches[row]<-TAIR10Func$Function[position[1]]

}

rfs19.122$functions <-matches
  • 1
    I think using `which` may be helpful here . Can you include `dput(head(rfs19.122))` and `dput(head(TAIR10Func))` in your post ? – Jd Baba Feb 24 '14 at 17:26
  • I want to say the `$` operator is slowing it down. Try using column numbers instead of the `$` operator and compare the two using `system.time` – Rich Scriven Feb 24 '14 at 17:26
  • 2
    If you were not a new user I would have downvoted this for not providing a minimal working data set. – Tyler Rinker Feb 24 '14 at 18:19
  • 1
    You want something like: http://stackoverflow.com/questions/15303283/how-to-do-vlookup-and-fill-down-like-in-excel-in-r – Thomas Feb 24 '14 at 18:56

0 Answers0