[R] indexing into a list

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Jun 12 09:20:04 CEST 2003


Anna H. Pryor wrote:

> I am trying to make an array of lists.  I don't think that I am doing it right 
> however because I cannot access the individual elements of the lists once I 
> have created the array of lists.  Can someone help?
> 
> 
> for(i in 1:3){
>      y[[i]] =  list(name[((i-1)*index+1):(i*index)])
>    }
> 
> Anna

Certainly you are not going to create an array of lists, but you are 
going to create "just" a list. See the manuals for details.

If "name" is an atomic vector, you won't need a list, but to stay within 
  your example:

  y[[i]] <- name[((i-1)*index+1):(i*index)]

to write the assignment's right hand side to the i-th element of list y.

Uwe Ligges




More information about the R-help mailing list