Re: [R] [Fwd: Re: How to apply functions over rows of multiple matrices]

2007-08-10 Thread Johannes Hüsing
> 1. matrices are stored columnwise so R is better at column-wise operations > than row-wise. I am seeing this by my code which contains more t() than what seems healthy. However, the summaries are patient-wise over repeated measurements. Out of convention, I am storing patients in rows and measur

Re: [R] [Fwd: Re: How to apply functions over rows of multiple matrices]

2007-08-10 Thread Gabor Grothendieck
1. matrices are stored columnwise so R is better at column-wise operations than row-wise. 2. Here is one way to do it (although I am not sure its better than the index approach): row.apply <- function(f, a, b) t(mapply(f, as.data.frame(t(a)), as.data.frame(t(b 3. The code for the ex

[R] [Fwd: Re: How to apply functions over rows of multiple matrices]

2007-08-10 Thread Johannes Hüsing
[Apologies to Gabor, who I sent a personal copy of the reply erroneously instead of posting to List directly] [...] > Perhaps what you really intend is to > take the average over those elements in each row of the first matrix which correspond to 1's in the second in the corresponding > row of the