[R] list()

Erik Iverson iverson at biostat.wisc.edu
Wed Mar 19 14:11:28 CET 2008


Scott -

Not sure about online references, I'm sure there are some.  But any R 
book should have a complete discussion of lists.

I learned from Modern Applied Statistics with S (MASS).  Under the 
"Books" section of www.r-project.org, you'll find a comprehensive list 
of books dealing with R, including MASS.

You can do the following to augment an already existing list.

model <- list(var1 = 5, var2 = 10)
model$var3 <- 20

Best,
Erik Iverson

Scott Romans wrote:
> Is anyone familiar with a good tutorial (in print or online) on the  
> use of list()? I found Matlab structures to be a great way to pass  
> complex variables (such as a model consisting of differently- 
> dimensioned variables) back and forth between functions. It seems  
> list() requires that you define the components within the command  
> (model <- list( var1 =" ", var2 = " ", etc) and that if you don't  
> fully define and name the component variables WITHIN the list command,  
> you won't be able to refer to them by name elsewhere. Instead, you  
> will have to remember the order and call the component variables as  
> model[[1]] etc. instead of model$var1. Is this a correct  
> understanding? Are there any good, comprehensive explanations on  
> list() with examples?
> 
> Thanks!
> 
> ______________________________________________
> 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