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

Kurt Hornik Kurt.Hornik at ci.tuwien.ac.at
Tue Nov 4 16:50:54 CET 1997


>>>>> 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
	  patient''

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?

-k
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



More information about the R-help mailing list