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,,])
}
- "E" is a 3-dimensional array filled with a given data X.
- "data" is a (nlon*nlat) matrix filled with given data Y.
- "G" is my output vector.
I want to apply the function "function.F", but this function has an
argument that depends
on the index "l" ...
Thanks for your help!
David
______________________________________________
R-help@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.