Re: [R] effective matrix subset

2008-08-10 Thread jgarcia
Patrick, you have misundertood me, I mean that Dan's solution (which is also your solution) are both: a) more clear and elegant b) more time efficient. I've checked it with my working 1*3000 element matrixes. The improvement in speed with your solution is evident. I do not advise at all to use

Re: [R] effective matrix subset

2008-08-10 Thread Patrick Burns
That may be a better solution, but I don't think it is clearly a better solution. I presume you mean that your computation is the most time efficient. That seems believable to me. It is not the most human efficient -- it will take some one reading the code non-trivial effort to understand it. W

Re: [R] effective matrix subset

2008-08-09 Thread jgarcia
It seems that this solution provided by Dan (and also available in SPoetry; I'm sorry I didn't notice it) is the fastest and simplest. I was using a more standard approach: V <- t(A)[(0:(nrow(A)-1))*ncol(A)+X], That wasn't bad, but I was confident that you, R gurus, could outperform this. This is

Re: [R] effective matrix subset

2008-08-09 Thread Marc Schwartz
on 08/09/2008 06:52 AM Dan Davison wrote: On Sat, Aug 09, 2008 at 06:29:59AM -0500, Marc Schwartz wrote: on 08/09/2008 06:01 AM [EMAIL PROTECTED] wrote: Hi; If we have a matrix A, and a vector X, where length(X)=nrow(A), and X contains a wanted column for each row in A, in row ascending order.

Re: [R] effective matrix subset

2008-08-09 Thread Dan Davison
On Sat, Aug 09, 2008 at 06:29:59AM -0500, Marc Schwartz wrote: > on 08/09/2008 06:01 AM [EMAIL PROTECTED] wrote: >> Hi; >> If we have a matrix A, and a vector X, where length(X)=nrow(A), and X >> contains a wanted column for each row in A, in row ascending order. How >> would be the most effective

Re: [R] effective matrix subset

2008-08-09 Thread Marc Schwartz
on 08/09/2008 06:01 AM [EMAIL PROTECTED] wrote: Hi; If we have a matrix A, and a vector X, where length(X)=nrow(A), and X contains a wanted column for each row in A, in row ascending order. How would be the most effective way to extract the desired vector V (with length(V)=nrow(A))? A <- matri

[R] effective matrix subset

2008-08-09 Thread jgarcia
Hi; If we have a matrix A, and a vector X, where length(X)=nrow(A), and X contains a wanted column for each row in A, in row ascending order. How would be the most effective way to extract the desired vector V (with length(V)=nrow(A))? Wishes, Javier __