[R] Avoiding loops & apply -function

From: David Masson <david.masson_at_env.ethz.ch>
Date: Wed, 05 Nov 2008 15:13:37 +0100

I have a question concerning avoiding loops. I know the function "apply" and I have used it several times, but I feel blocked
with this situation :

E <- array(X, dim = c(L,nlon,nlat) )
data <- matrix(Y, nrow=nlon, ncol=nlat ) G <- vector(length=L)

   for (l in 1:L)
      G[l] <- function.F(data,E[l,,])

I want to apply the function "function.F", but this function has an argument that depends
on the index "l" ...

Thanks for your help!


R-help_at_r-project.org 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. Received on Wed 05 Nov 2008 - 14:16:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Nov 2008 - 15:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive