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

Simon Fear fear at scmp.scm.liv.ac.uk
Mon Nov 3 11:41:41 CET 1997

> 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'm sending this to the list because I'm interested in views re Ross' comment:

> Trying to work using record-like ideas is at best awkward in S/R and
> it will probably be very inefficient.

And yet StatSci do so love to peddle S-PLUS as object-oriented. An object 
Person, a constructor Person() and a holder for them, PersonList, is totally 
natural and efficient in a real object-oriented environment such as C++. Such 
objects would have to be implemented using the fundamental list construct within 
S/R. Is this really so inefficient? If so why?

Personally I think selling S-PLUS as object-oriented might be a prosecutable 
offence. It is object-added. (R is free: I don't care what it claims to be :-)

Simon Fear
scf at liv.ac.uk
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