Re: [R] Merging two dataframes with a condition involving variables of both dataframes

2013-11-07 Thread Collin Lynch
You might need to implement it as a nested pair of for loops using rbind. In essence iterate over the rows in df1 and each time find the matching row in df2. If none is found then add the df1 row by itself to the result. If one is then remove it from df2 and rbind both of them. Once done just me

[R] Merging two dataframes with a condition involving variables of both dataframes

2013-11-07 Thread Marc MarĂ­ Dell'Olmo
Dear all, I would like to merge two dataframes using two conditions. For example, if I have the dataframes df1 and df2: > (df1 <- data.frame(var1=c("a","b","d","e","g"), var2=c(25,14,53,26,84), infodf1=c(1,1,1,1,1))) var1 var2 infodf1 1a 25 1 2b 14 1 3d 53 1