[R] separate row averages for different parts of an array

vincent at 7d4.com vincent at 7d4.com
Thu Aug 17 07:23:02 CEST 2006


Spencer Jones a écrit :

> I have an array with 44800 columns and 24 rows I would like to compute the
> row average for the array 100 columns at a time, so I would like to end up
> with an array of 24 rows x 448 columns. I have tried using apply(dataset, 1,
> function(x) mean(x[])), but I am not sure how to get it to take the average
> 100 columns at a time. Any ideas would be  welcomed.
> thanks,
> Spencer

?rowSums, ?rowMeans
something like : rowMeans(my_array[,1:100])
(perhaps you'll have to use t() also)
hih



More information about the R-help mailing list