It's certainly possible and I don't think you get any grueling
inefficiencies. along the way.

Another way that might or might not make sense for you is to use a
nifty trick I saw Gabor and Duncan M use a few weeks ago: you can give
dimensionality to a list and then subset it in the "normal" ways:
e.g.,

x <- list(a = 1, b = 2, c = 3, d = 4)
dim(x) <- c(2,2)
colnames(x) <- c("a", "b")

x[2,]
x[,2]

x[[2]]]

x[,"a"]

Might be of help for some nifty indexing. (Or it might look so crazy
to scare folks away: your call)

Michael
On Wed, Feb 22, 2012 at 10:17 AM, Stefano Sofia
<stefano.so...@regione.marche.it> wrote:
> Dear R users,
> I have difficulty to create a list within a list.
> Example: with
>
>> A <- vector(mode="list", 4)
>
> I create a list of 4 elements:
>> A
> [[1]]
> NULL
>
> [[2]]
> NULL
>
> [[3]]
> NULL
>
> [[4]]
> NULL
>
> In each element of this list I can store, for example, a matrix:
> A[[1]] <- matrix ...
>
> I need each element of A to be a list (all the lists of the same length), and 
> then store matrices within these lists.
> Have I explained it in a reasonable way?
> Is it possible?
> If yes, is it efficient? For my purposes, I need to have A a list of length 
> 20000 or 30000 (even 50000 possibily), and the lists within A of length 1000 
> and store square matrices of dimension 13.
>
> Thank you for your attention and your help
> Stefano Sofia PhD
>
>
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
> alla ricezione. I messaggi di posta elettronica per i client di Regione 
> Marche possono contenere informazioni confidenziali e con privilegi legali. 
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o 
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, 
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio 
> computer. Ai sensi dell’art. 6 della  DGR n. 1394/2008 si segnala che, in 
> caso di necessità ed urgenza, la risposta al presente messaggio di posta 
> elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by 
> persons entitled to receive the confidential information it may contain. 
> E-mail messages to clients of Regione Marche may contain information that is 
> confidential and legally privileged. Please do not read, copy, forward, or 
> store this message unless you are an intended recipient of it. If you have 
> received this message in error, please forward it to the sender and delete it 
> completely from your computer system.
> ______________________________________________
> R-help@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.

______________________________________________
R-help@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.

Reply via email to