For each row in an R dataframe

You can use the by() function: by(dataFrame, seq_len(nrow(dataFrame)), function(row) dostuff) But iterating over the rows directly like this is rarely what you want to; you should try to vectorize instead. Can I ask what the actual work in the loop is doing?

Compare two data.frames to find the rows in data.frame 1 that are not present in data.frame 2

sqldf provides a nice solution a1 <- data.frame(a = 1:5, b=letters[1:5]) a2 <- data.frame(a = 1:3, b=letters[1:3]) require(sqldf) a1NotIna2 <- sqldf(‘SELECT * FROM a1 EXCEPT SELECT * FROM a2’) And the rows which are in both data frames: a1Ina2 <- sqldf(‘SELECT * FROM a1 INTERSECT SELECT * FROM a2’) The new version of dplyr has … Read more