Skip to content

Programming objects in R

6 messages · Tom Backer Johnsen, Wacek Kusnierczyk, Martin Morgan +2 more

#
This is interesting.  The fact that there are so few texts on the 
subject probably means that very few are using OO programming methods in 
R.

I will probably look in the Python direction.  Pity.  I would have 
preferred R.

Tom
krzysztof.sakrejda at gmail.com wrote:

  
    
#
Tom Backer Johnsen wrote:
if you insist on oo, python might be a better choice.  r has two
built-in oo systems plus a few additional ones in various packages. 

of the two basic ones, s3 is simple to use though some features may
confuse you;  in his The R Inferno [1], Pat Burns calls this system 'a
bit ad hoc'.

the other, s4, is much more complex, probably too complex for its own
developers.  additionally, s3 and s4 intefere with each other in ugly
ways, as some recent posts show.  here's one opinion:

    library(fortunes)
    fortune('handcuff')

if you really have to stay with r, R.oo, for example, might be an
alternative.

you can always access r from within python when statistic computations
are needed, while staying in the cosy realm of a much more coherent
programming language.

vQ

[1] http://www.burns-stat.com/pages/Tutor/R_inferno.pdf
#
Tom Backer Johnsen <backer at psych.uib.no> writes:
Using python is great; your deduction about use of OO in R harder to
support. The Bioconductor project (300+ packages, not all with strong
OO components) makes extensive use of S4, as does the Matrix
recommended package, for instance; S4 really opens the door to more
complex OO approaches, but a very large number of packages use OO
concepts under the S3 object system.

Martin

  
    
#
Wacek Kusnierczyk wrote:
Very true.  Sounds like sensible advice.

Tom

  
    
#
Tom Backer Johnsen wrote:
That's overstating the problem.  I frequently run into OO R packages and 
many of them are very nicely done.  Some good examples you could follow 
are the packages: 'simecol','lme4', and 'pomp'.

The main issue I see is that R's OO model is different than C++/PHP/Java 
(the ones I'm familiar with).  Due to that difference a resource tightly 
focused on programming technique would be very valuable---it would make 
the process of getting into writing 'correct' OO packages simpler.

Best,

Krzysztof

-----------------------------------------------
Krzysztof Sakrejda-Leavitt

Organismic and Evolutionary Biology
University of Massachusetts, Amherst
319 Morrill Science Center South
611 N. Pleasant Street
Amherst, MA 01003

work #: 413-325-6555
email: sakrejda at nsm.umass.edu
#
While not wholly directed towards OO programming, 'R Programming for 
Bioinformatics' does cover both the S3 and S4 systems (and how to make 
them play nicely together) at an accessible level.

http://www.bioconductor.org/pub/RBioinf/

Best,

Jim
Krzysztof Sakrejda-Leavitt wrote: