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

Ross Ihaka ihaka at stat.auckland.ac.nz
Sun Nov 2 21:30:00 CET 1997


> 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 )

As you observe, the focus in this kind of language is on "variables"
rather than on "cases".  I think that this is because statistics tends
to be about building models with collections of observations, rather
than answering queries about individual observations.  Many computations
in R/S take advantage of this variable/vector structure.

Trying to work using record-like ideas is at best awkward in S/R, and
it will probably be very inefficient.  When records are of fixed size,
you can get the same effect by using data frames, but you have to think
variable-wise rather than case-wise.

I think the reason that S has caught on among statisticians is that we
have been trained to think in terms on "modeling with variables".  It
seems like the most natural thing in world to us.  Similarly, MATLAB
users probably like MATLAB because they have been trained to see
everything as a matrix problem and this is the framework that MATLAB
presents.  It is always interesting to encounter someone from a different
background who doesn't see things the same way.

If you are really interested in casewise processing I would suggest
that XLispStat or some other Lisp/Scheme may be a better choice.

	Ross
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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