Skip to content

more efficient sum of matrix columns

1 message · Jonck van der Kogel

#
Hi,
Maybe I'm not understanding you correctly, but wouldn't the following 
be the fastest way to compute the sum of a column:

 > x <- matrix(c(1:4462), nrow=4462, ncol=1) #setting up a column of 
4462 elements to be able to make a comparison
 > sum(x[,1])
[1] 9956953
 > system.time(sum(x[,1]))
[1] 0 0 0 0 0

As you can see this took so little time it actually came out as 0. And 
my system is not fast at all (powermac 9600 with a G4 700 MHz upgrade).
HTH, Jonck