Skip to content

syntax for a list of components from a list

2 messages · Maas James Dr (MED), Joshua Wiley

#
Hi,
On Thu, Jan 20, 2011 at 6:59 AM, Maas James Dr (MED) <J.Maas at uea.ac.uk> wrote:
This is close, but using the `[[` operator is not quite what you want here.

myl <- rep(list(matrix(1:9, 3)), 9)

length(myl) # look at the length of the list (9)
myl[1:3] # select elements 1:3 of the list

## Contrast this with:

myl[[1:2]] # select the 1st element of the list, then the 2nd element of that
myl[[c(3, 1)]] # 3rd element of list, 1st element of that

## This does what you want I think
require(abind) # load relevant package
abind(myl[1:3], along = 3)


Cheers,

Josh