Re: [R] Trying to avoid the loop while merging two data frames

2015-12-22 Thread Dimitri Liakhovitski
Taking it back - no need for all.x = T, all.y = F On Tue, Dec 22, 2015 at 3:56 PM, Dimitri Liakhovitski wrote: > Actually, the correct merge line should be: > my.merge <- merge(myinfo, mydata, by="version", all.x = T, all.y = F) > > On Tue, Dec 22, 2015 at 3:50 PM, Dimitri Liakhovitski > wrote:

Re: [R] Trying to avoid the loop while merging two data frames

2015-12-22 Thread Dimitri Liakhovitski
Actually, the correct merge line should be: my.merge <- merge(myinfo, mydata, by="version", all.x = T, all.y = F) On Tue, Dec 22, 2015 at 3:50 PM, Dimitri Liakhovitski wrote: > You are right, guys, merge is working. Somehow I was under the > erroneous impression that because the second data frame

Re: [R] Trying to avoid the loop while merging two data frames

2015-12-22 Thread Dimitri Liakhovitski
You are right, guys, merge is working. Somehow I was under the erroneous impression that because the second data frame (myinfo) contains no column 'myid' merge will not work. Below is the cleaner code and comparison: # ### Example with smaller data frames ##

Re: [R] Trying to avoid the loop while merging two data frames

2015-12-22 Thread Dimitri Liakhovitski
I know I am overwriting. merge doesn't solve it because each version in mydata is given to more than one id. Hence, I thought I can't merge by version. I am not sure how to answer the question about "the problem". I described the current state and the desired state. If possible, I'd like to get fro

Re: [R] Trying to avoid the loop while merging two data frames

2015-12-22 Thread Giorgio Garziano
Library dplyr to use arrange() for ordering, in the case. library(dplyr) result.order <- arrange(result, d, version, a, b, c) dim(result.order) [1] 30005 head(result.order) d versiona b c 1 -2.986456069 1 0.2236414154 0.004258038663 1.089

Re: [R] Trying to avoid the loop while merging two data frames

2015-12-22 Thread jim holtman
You seem to be saving 'myid' and then overwriting it with the last statement: result[[i]] <- result[[i]][c(5, 1:4)] Why doesn't 'merge' work for you? I tried it on your data, and seem to get back the same number of rows; may not be in the same order, but the content looks the same, and it does