Skip to content

indexing into a list 2

2 messages · Anna H. Pryor, Uwe Ligges

#
I didn't explain myself well.

You are right about not needing a list on the right hand side of the equation 
below.  What I end up with is a list of arrays.  Now what i would like to do 
is to access the individual elements in the arrays in the list.  For example, 
when I type, y[[1]], I just get the whole first array.  How do I get the 
first element in the first  array for instance?  Is that not possible?

Anna
Anna H. Pryor wrote:

            
right
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
#
Anna H. Pryor wrote:

            
Just "append" that index. E.g., if your array in y[[1]] is 3D,
  y[[1]][1,1,1]
or maybe you mean
  y[[1]][ , , 1]

Uwe Ligges