I would like to port the SpecialK Poker Hand evaluator to R. I think this should be relatively easy using the Rcpp package, but I have no idea where to begin.

The existing tutorials seem to focus on developing new C++ code for use in R. In this case, I have C++ that solves a problem, and I want to use this code in R with minimum hassle. If the code were one, self-contained function, I could compile and link it on the fly with inline, but this doesn't work here.

I guess this question has 2 parts:

  1. Will I need to make any changes to the C++ source to make it compatible with Rcpp?
  2. How do I call this code from R, given that it's not a small, self-contained function I can compile and link dynamically using inline?

I am also open to using the Java, python, or objective-C versions of the evaluator, but I don't think those will be easier to link to R.

有帮助吗?

解决方案

Have you looked at Rcpp which makes it fairly painfree to combine R and C++?

Lots of packages use it to bring existing C++ code to R. You can also look at questions here under the [rcpp] tag. Fairly extensive documentation in the package, at my site and other places.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top