Sorry folks I posted the code with a bug in approach 2. aarrrhh. it should have 
been...

## Approach 2: loop on k2
output2 = matrix(0,nrow=n,ncol=k2)
pt2 = proc.time(for (i in 1:k2) output2[,i] = rowSums( m1*(m2[,rep(i,3)]) ))
 
> I haven't seen any other response yet (after 8 hours!) but doesn't:
> rowSums(m1)*m2
> do what you want?
> 
> HTH
> Ray Brownrigg

... which is a very long winded way to do exactly what Ray did very
easily. Thanks for the pointer Ray.

Dave

______________________________________________
[email protected] 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