On Nov 30, 2009, at 11:10 AM, Will Carr wrote:


Working with an NxMxO sized matrix, currently I can do this in my code:

What are M, N, and O? All the same magnitude?

if (max(colSums(array)) >= number)

But to get an equivalent result using rowSums, I have to do:

for (i in 1:10)
{
if (max(rowSums(array[,,i])) >= number)

What are you doing based on that if( ) determination?

}

I'm running both in a much larger loop that loops millions of times, so speed and such is quite a big factor for me. Currently, the colSums line uses about 1/10th as much time as the rowSums' for loop, and the for loop actually took as much time as the rest of my code combined took to execute.

Are you sure you are interpreting your profile results correctly?

Is there a faster way than using a for loop and rowSums?

It may depend on what you are trying to do, which at the moment is most unclear.

--
View this message in context: 
http://n4.nabble.com/command-similar-to-colSums-for-rowSums-tp931394p931394.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to