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

Kurt Hornik (
Tue, 4 Nov 1997 16:50:54 +0100

Date: Tue, 4 Nov 1997 16:50:54 +0100
Message-Id: <199711041550.QAA07560@pc25.none>
From: Kurt Hornik <>
To: (Simon Fear)
Subject: Re: R-beta: A vector of lists == Data Frame?
In-Reply-To: <>

>>>>> Simon Fear writes:

>> What is the most common R/S idiom for creating a vector of lists and 
>> then adding new lists to it?

> I would suggest you use a list of lists instead of a vector of
> lists. If as you say you are a real beginner in R/S (but obviously not
> to programming), are you aware of use of double brackets to get list
> elements? ie mylist[i] returns the element as a list of length one,
> almost always not what you want, which is mylist[[i]]. Given this,
> lists are pretty easy to use; in fact, you can do without vectors. As
> Ross Ihaka says, this would probably be more natural in Xlispstat or
> straight Lisp.

> BTW To find out about R's object-oriented methods, you need help(class); 
> help(object) draws a blank.

I agree that all low-level tools to work with record-like strucures (in
particular lapply() are there).  But, suppose for example that you have
a variable number of measurements of a variable V for a number of
patients.  (Typical biostat problem.)  What you'd like to say is,

	``do something with V (e.g., plot it as a time series) for each

How can this be done in a simple and straightforward manner?  Also, how
can you e.g. get a vector with the average V for each patient (from a
list of lists)?

Btw, how do you store such data?

r-help mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: