A quicker way...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

A quicker way...

peleve
This post has NOT been accepted by the mailing list yet.
I have the following loop structure, where lxx and lyy are large (>10,000)  It's taking a long time to run.  Is there a more efficient way to do this?
I guess that the *apply functions could be used, but I can;t get my hands arround how to use them.

Thanks for any help.

k <- 0
for(i in 1:lxx){
        for(j in 1:lyy){
                k <- k + 1
                locx[k] <- xx[i]
                locy[k] <- yy[j]
                dept[k] <- zz[i,j]
        }
}


Pete versteegen
Reply | Threaded
Open this post in threaded view
|

Re: A quicker way...

Bart Joosen
This post has NOT been accepted by the mailing list yet.
You didn't provide any data, so I must guess as it isn't clear what you want as an output.

locx seems like rep(xx, each=length(lyy))
locy seems like rep(yy, length(lxx))
dept seems like as.vector(zz) (if zz is a matrix)

HTH

Bart