R-beta: A vector of lists == Data Frame?

Brent Hutto (BHutto@IBM.Net)
Sun, 2 Nov 1997 09:30:40 +0000

Message-Id: <199711021430.OAA128446@out2.ibm.net>
From: "Brent Hutto" <BHutto@IBM.Net>
To: r-help@stat.math.ethz.ch
Date: Sun, 2 Nov 1997 09:30:40 +0000
Subject: R-beta: A vector of lists == Data Frame?

I hope a very basic R/S programming question is appropriate for this 

I have a function which returns a list of several (named) numeric 
values characterising an event history for a person. I want to invoke 
the function many (1000) times and create a vector of these lists to 
represent the histories of a population.

At first, I thought that a data frame would be the appropriate way to 
store the whole population record. But upon some reading in "Modern 
Applied Statistics with S-plus" (Venables and Ripley, 1994) it seems 
that a data frame is more like a list of vectors (all of the same 
length) than a vector of lists.

What is the most common R/S idiom for creating a vector of lists and 
then adding new lists to it? To be more specific, if "CreatePerson" 
is a function that returns a list characterising that person, how do 
I implement the following pseudo-code in R

Person[ i ] <- CreatePerson( param1, param2 )

Where Person[ 1000 ] is a vector of lists of the type returned by the 
"CreatePerson" function? When I'm done, I want to do things like the 
following pseudo-code

Person[ j ]$Age <- Person[ j ]$Age + 1

or similar (actually, that particular piece of logic isn't 
necessarily one I'm likely to do).

Any guidance is appreciated as are suggestions for a text to 
supplement Venables and Ripley in learning this language from 
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch