[R] Creating an array of lists
Dan Davison
davison at stats.ox.ac.uk
Thu Aug 7 19:26:20 CEST 2008
Gang Chen-4 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)
>
Note that in R terminology, 'myArray' is a list, not an array. You are right
to store things like lm() output in a list. If you want to store multiple lm
outputs in a way that is conceptually multi-dimensional, I would suggest
using lists of lists. Then you can use rapply(lm.fits, some.function,
how=replace) to process the model fits while keeping the multi-dimensional
structure.
Dan
Gang Chen-4 wrote:
>
> 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.
>
>
--
View this message in context: http://www.nabble.com/Creating-an-array-of-lists-tp18874326p18875567.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list