Z P wrote:
> Dear all,
>
> I now have a sequence of n<-3:21, for each i, I define an array of
> dimension
> array((1/2)^i,c(rep(2,i))), I must update the (i+1)-th array with a loop
> according to the i-th array, How can I store all the previous arrays
> (the marginal parts of the (i+1)-th array will not equal to the i-th
> array)? It is in an iteration from 3 to 21, I later will need all the
> arrays. If I define 19 different variables, I still can not assign
> arrays to them in the iteration. What can I do? Thanks.
>
> Regards,
>
> Zhen
Use a list as in:
Alist <- vector(21, mode="list")
n <- 3:21
for(i in n){
Alist[[i]] <- array(1/2^i, rep(2,i))
}
with Alist[[3]] as the first non-NULL element, or:
Alist <- lapply(3:21, function(i) array(1/2^i, rep(2,i)))
with Alist[[1]] as the first non-NULL element
Uwe Ligges
PS: Why do you ask R-help in CC, and other people as the main addresses?