[R] Creating an array of lists

Patrick Burns pburns at pburns.seanet.com
Thu Aug 7 22:05:38 CEST 2008


myListArray <- array(list(NULL), c(3,2))
myListArray[[1,2]] <- list(letters, 1:4)

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Gang Chen wrote:
> Hi,
>
> I want to store some number of outputs from running a bunch of
> analyses such as lm() into an array. I know how to do this with a
> one-dimensional array (vector) by creating
>
> myArray <- vector(mode='list', length=10)
>
> and storing each lm() result into a component of myArray.
>
> My question is, how can do this for a multiple dimensional array? It
> seems array() does not have such a 'mode' option as in vector(). Any
> alternatives?
>
> Thanks in advance,
> Gang
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>



More information about the R-help mailing list