I have been implementing binary tree search algorithm recently in R, and before that I used linked array-like structures. These algorithm would be much easier if there were pointers in R (not C pointers, but references to objects). I wonder if there is a workaround. I don't know S4 at all; maybe it is possible in that framework? I would avoid environment-related tricks, since that pass-by-reference is a little too bit of a workaround. And I would avoid invocations of C or C++'s STL. It's an R question after all.
R 2.12 will start to bring you some of this. In the meantime, the common recommendation is to use environments to approximate call-by-reference.
You might also be interested in the binsearch()
function from the genetics
package: http://www.biometrics.mtu.edu/CRAN/web/packages/genetics/index.html . It implements a binary search.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With