[R] truly object oriented programming in R

"Jens Oehlschlägel" joehl at gmx.de
Fri Aug 13 10:45:09 CEST 2004

Dear Jason,

Of course you can do almost eveything in R, but I have rarely seen someone
prototyping something in Java to then implement it in R. KD-trees are for
performance, and interpreted R is not really fast. So interfacing some
foreign code might really be the better choice here.

Opportunity 1
Since you have already Java code, the most straightforward choice might seem
interfacing the Java code via SJava or RJava. However, though there are
packages RJava and SJava, it looks like there is no recommended Java
interface which is maintained across all relevant platforms, and thus
nothing at CRAN. Given the richness of available Java software, this is a
pitty, but a reality. I am currently trying to remove remaining memory leaks
from SJava 0.66 for Windows, but this is a one time effort, not a
maintenance promise.

Opportunity 2
Get some standard KD-tree C-code and modify it to your needs. Then interface
it using the C- or Call-interface, to write an access function for every
operation you want to perform on the KD-tree from R.

Opportunity 3
Write your own C-code operating directly on R-data structures. In this case
you do not only interface a KD-tree, you really have it in R but you can
have the most important operations coded in C. But this is the technically
most challenging one. You need to to know C, read "Writing R Extensions"
very carefully, you need to understand the sets of macros defined in
Rdefines.h and Rinternals.h, especially you need to understand all the
PROTECT macros and how to avoid overloading the protect-stack, because you
will need to reprotect your KD-tree very often.

Hope that helps


Jens Oehlschlägel

NEU: WLAN-Router für 0,- EUR* - auch für DSL-Wechsler!
GMX DSL = supergünstig & kabellos http://www.gmx.net/de/go/dsl

More information about the R-help mailing list