Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
That's much more fair I failed to note that extra line of work. Good to know looping can be avoided. Thanks! -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: August 20, 2013 11:11 AM To: Folkes, Michael Cc: R help Subject: Re: function on columns of two arrays Hi Mich

Re: [R] function on columns of two arrays

2013-08-20 Thread arun
Hi Michael, I run it on my system after deleting one of the lines from method1 (as it was not necessary) method1 <- function(){   a1<- data.frame(a)   b1<- data.frame(b)   lapply(seq_len(ncol(a1)),function(i) summary(lm(b1[,i]~a1[,i]))$coef) } linRegFun<- function(x,y){  res<- summary(lm(y~x))$

Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
Here's a tiny summary of the speed results using different methods to run lm on common columns from two arrays. Sadly looping is fastest. I don't know if any are sensitive to array dimensions (more columns, fewer layers etc). I invite correction, or suggestions for improvement to avoid looping. Goi

Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
97203-5452 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Folkes, Michael Sent: Tuesday, August 20, 2013 12:34 AM To: r-help@r-project.org Subject: [R] function on columns of two arrays I've spent a bit too long searching the h

Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
l" To: r-help@r-project.org Cc: Sent: Tuesday, August 20, 2013 3:34 AM Subject: [R] function on columns of two arrays I've spent a bit too long searching the help history and attempting to apply some logic to the following: I have two 3D arrays each with same dim. I wish to run lm on the r

Re: [R] function on columns of two arrays

2013-08-20 Thread Law, Jason
Avenue Portland, OR 97203-5452 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Folkes, Michael Sent: Tuesday, August 20, 2013 12:34 AM To: r-help@r-project.org Subject: [R] function on columns of two arrays I've spent a bit too lon

Re: [R] function on columns of two arrays

2013-08-20 Thread arun
iginal Message - From: arun To: "Folkes, Michael" Cc: R help Sent: Tuesday, August 20, 2013 7:42 AM Subject: Re: [R] function on columns of two arrays Hi, May be this helps.   a1<- data.frame(a)  b1<- data.frame(b)  lapply(seq_len(ncol(a1)),function(i) lm(b1[,i]~a1[,i]))  lap

Re: [R] function on columns of two arrays

2013-08-20 Thread arun
: Sent: Tuesday, August 20, 2013 3:34 AM Subject: [R] function on columns of two arrays I've spent a bit too long searching the help history and attempting to apply some logic to the following: I have two 3D arrays each with same dim. I wish to run lm on the respective columns of each arra

[R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
I've spent a bit too long searching the help history and attempting to apply some logic to the following: I have two 3D arrays each with same dim. I wish to run lm on the respective columns of each array, preferably without loops. We often hear chatter that sometimes apply() won't be faster "just