Re: [R] Merging data in arrays

2013-02-23 Thread Jeff Newmiller
There is a reason why merge is not designed to work directly with arrays: the matching of rows can easily yield a result with a different number of rows than the initial data had. This plays havoc with the nature of arrays. I would recommend that if a merge is really what you want then

Re: [R] Merging data in arrays

2013-02-22 Thread Rui Barradas
Hello, I bet there are simpler solutions but I'm not thinking of anything else, right now. fun - function(x, y){ f - function(a, b){ a - as.data.frame(a) b - as.data.frame(b) names(a)[1] - names(b)[1] - V1 res - merge(b,

Re: [R] Merging data in arrays

2013-02-21 Thread Ray Cheung
Dear All, I've 2 arrays A and B: dim(A) = 100, 10, 1000 dim(B) = 100, 20, 900 I know there are 5 columns of values common to both arrays. I want to ask how to merge the 2 arrays. Thanks in advance! Best Regards, Ray [[alternative HTML version deleted]]

Re: [R] Merging data in arrays

2013-02-21 Thread Jeff Newmiller
I think this specification is insufficient to respond accurately to. Please make a reproducible subset of your data (or simulated data) and provide it in dput form, and describe your desired result data set more clearly.

Re: [R] Merging data in arrays

2013-02-21 Thread Ray Cheung
Thanks, Jeff. Here is a simplified hypothetical sample (sorry for the clumsy code): A1 - matrix(1:5, nrow=5, ncol=1) A2 - matrix(6:10, nrow=5, ncol=1) A3 - matrix(11:15, nrow=5, ncol=1) A4 - matrix(16:20, nrow=5, ncol=1) A5 - matrix(21:25, nrow=5, ncol=1) A6 - matrix(26:30, nrow=5, ncol=1) B1 -

Re: [R] Merging data in arrays

2013-02-07 Thread arun
Hi, I didn't fully understand the logic. You could get the result by:  list1-lapply(mapply(cbind,lapply(1:2,function(i) E[,,i]),lapply(c(1,3),function(i) C[,i,]),SIMPLIFY=FALSE),function(x) x[,c(TRUE,apply(matrix(!x[,-1]%in% x[,1],nrow=5),2,all))])

Re: [R] Merging data in arrays

2013-02-07 Thread Ray Cheung
Thanks for the codes. Maybe I elaborate more here. In my actual dataset, the dim(E) = (200, 20, 1000) and dim(C) = (200,15, 965) in which I don't know which 35 matrix are missing. I want to ask how merge the two arrays by matching the first 5 columns of values. Thanks you. Best Regards, Ray On