Try this:
aperm(outer(i %o% k, j, FUN = "-"), c(1, 3, 2))
On Fri, Jan 29, 2010 at 9:58 AM, Kohleth Chia wrote:
> Hi,
>
> How can we vectorize multiple for loops?
>
> E.g. how do you vectorize this:
>
> for (i in 1:10){
> for(j in 1:25){
> for(k in 1:19){
> x[i,j,k]=i*k-j
> }
> }
> }
>
> T
Hi,
How can we vectorize multiple for loops?
E.g. how do you vectorize this:
for (i in 1:10){
for(j in 1:25){
for(k in 1:19){
x[i,j,k]=i*k-j
}
}
}
THanks
KC
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listi
2 matches
Mail list logo