[R] removing for loop
Uwe Ligges
ligges at statistik.uni-dortmund.de
Tue Jul 4 11:52:49 CEST 2006
vincent at 7d4.com wrote:
> Dear Rusers,
>
> Trying to reduce my for loops addiction,
> could somebody tell me if there are ways to simplify
> (and perhaps accelerate ?) the following line
>
> for (i in 1:N) for (j in 1:N) m[i,j] = b[i]-b[j];
outer(b, b, "-")
Uwe Ligges
> (where m is a NxN matrix and b a vector of length N)
>
> Thanks for any hint.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list