[R] To implement OO or not in R package, and if so, how to structure it?

Hadley Wickham h.wickham at gmail.com
Thu Sep 14 15:29:46 CEST 2017


I just finished the first draft of the chapters on OO programming for
the 2nd edition of "Advanced R": https://adv-r.hadley.nz - you might
find them helpful.

Hadley

On Thu, Sep 14, 2017 at 7:58 AM, Alexander Shenkin <ashenkin at ufl.edu> wrote:
> Hello all,
>
> I am trying to decide how to structure an R package.  Specifically, do I use
> OO classes, or just provide functions?  If the former, how should I
> structure the objects in relation to the type of data the package is
> intended to manage?
>
> I have searched for, but haven't found, resources that guide one in the
> *decision* about whether to implement OO frameworks or not in one's R
> package.  I suspect I should, but the utility of the package would be aided
> by *collections* of objects.  R, however, doesn't seem to implement
> collections.
>
> Background: I am writing an R package that will provide a framework for
> analyzing structural models of trees (as in trees made of wood, not
> statistical trees).  These models are generated from laser scanning
> instruments and model fitting algorithms, and hence may have aspects that
> are data-heavy.  Furthermore, coputing metrics based on these structures can
> be computationally heavy.  Finally, as a result, each tree has a number of
> metrics associated with it (which may be expensive to calculate), along with
> the underlying data of that tree.  It will be important as well to perform
> calculations across many of these trees, as one would do in a dataframe.
>
> This last point is important: if one organizes data across potentially
> thousands of objects, how easy or hard is it to massage properties of those
> objects into a dataframe for analysis?
>
> Thank you in advance for thoughts and pointers.
>
> Allie
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
http://hadley.nz



More information about the R-help mailing list