[R] Another loop avoidance question.
David
dpleydel at univ-fcomte.fr
Fri Jun 29 13:20:05 CEST 2007
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
More information about the R-help
mailing list