[R] Help with R

Gabor Grothendieck ggrothendieck at gmail.com
Fri May 20 04:12:24 CEST 2005


On 5/19/05, Ted Harding <Ted.Harding at nessie.mcc.ac.uk> wrote:
> Hi Gabor,
> 
> On 05-May-05 Gabor Grothendieck wrote:
> > On 5/5/05, Ted Harding <Ted.Harding at nessie.mcc.ac.uk> wrote:
> >> [...]
> >> However, while representing the raw data in such a form is
> >> well supported by R, it seems to me that extracting data
> >> in a way adapted to different analyses requires users to
> >> create their own methods, using the list-access primitives .
> >>
> >> For example, to study the changes in the distribution of
> >> lengths of specimens in relation to Position and Date
> >> (which was one of the important issues in that investigation),
> >> I don't think there are any "list processing" functions
> >> available in R which, given the list-based structure described
> >> above, would allow a simple query of the form
> >>
> >>  means( Length , ~ Position:Date , data=Cruise )
> >>
> >> It's quite feasible to write one's own; but I think Peter's
> >> hope (expressed in excerpt above) looks like a first call
> >> for thinking about general methods for this sort of thing.
> >>
> >
> > The Green Book defines a recursive apply function, rapply,
> > that provides a general means of traversing that
> > sort of structure.
> > [...]
> >  R. A. Becker, J. M. Chambers, and A .R. Wilks, The New S Language:
> >    A Programming Environment for Data Analysis and Statistics.
> >    Pacific Grove, CA: Wadsworth, 1988. Defines S Version 2, which
> >    forms the basis of the currently used S Versions 3 and 4, as well
> >    as R. (Sometimes called the "Blue Book.")
> 
> Thanks for your suggestions and comments, Gabor.
> 
> However, I now have the Green Book. There is some mention of
> 'rapply' (pp. 174-5, 371 where the function is used in the
> definition of a function, and 430 where it is stated that "The
> S and C computations for rapply follow the style of the example
> here", the example in question being C code for "a simplified
> version of the S function lapply"). However, there is no code
> anywhere for rapply itself!
> 
> While the above possibly amount to enough hints for a good R
> programmer to work out an implementation for rapply, this is at
> present a level or two above my skills.
> 
> The S-plus code for rapply can be found by listing "rapply".
> There are two things wrong with doing this. One is that this
> code involves at least two functions which do not seem to
> be available in R -- new.frame() and the function which
> occurs in .Call(2s_tree_apply", .... ). One would need to
> infer what these do and implement them in R.
> 
> The other is that I'm not at all keen on the idea of pinching
> code from a proprietary product (S-plus).
> 
> So I'm wondering if there is any R code that implements the
> equivalent of 'rapply' or could readily be extended to do so.

Search r-help for treeapply.   Also r-devel for a link to the codetools 
package which has some recursive code in it.




More information about the R-help mailing list