[R] filling an array, vectorized
    Tamas K Papp 
    tpapp at Princeton.EDU
       
    Wed Nov 15 20:16:11 CET 2006
    
    
  
Hi,
I am sure this has come up before, but my searches of the archive
didn't give any results (maybe I didn't use the right keywords, but if
I use too many, the search times out).
I have a vector of dimensions n, length is not fixed, eg
n <- c(4,5,7)
or 
n <- c(19,4,5,7)
and a function f that takes a vector of indices, same length of n, and
gives a scalar.
I would like to fill the array
a <- array(dim=n)
so that (... is just notation, not R's ...)
a[i,j,k,...] <- f(list(i,j,k,...))
I would use loops, but since n can have different lengths, I don't
know how many loops I would need beforehand.  Is there a way to do
this?
Thanks,
Tamas
    
    
More information about the R-help
mailing list