Hello,

I'm trying to run user provided R scripts from within my C++ applications using RInside. I have a large amount of data (larger than RAM) the R script can potentially access, so it's impossible to provide it all in a variable - I'd need to provide a callback so the R script can request the data it needs.

The idea is to have a function similar to sample9 (minus the bug[1])

Rcpp::NumericVector getdata(int id) {
        Rcpp::NumericVector vec();
        // ...
        return vec;
}

and make it available like:

RInside R;
R["getdata"] = Rcpp::InternalFunction( &getdata );



As hinted in sample9, Rcpp::InternalFunction apparently really is broken. Instantiating it gives compiler errors very similar to those everyone got in Rcpp 0.11.0. [2]

I've updated both Rcpp and RInside to the latest release version, but the errors remain.



Am I doing something wrong, or is this feature fundamentally broken? Is there anything I can do to fix it?

Or are there other ways to add a function to the R script's environment? I've read of plenty of ways using Rcpp, but those only seem to apply when developing R packages. I could provide an R package, include it from the RInside script and thus have a custom function; but the R package would be separate from my application and wouldn't have access to the data it needs to provide.


Or should I just install older RInside/Rcpp packages where it still compiled, and work with those for now?



[1] return result.c_str(); returns a dangling pointer, since result is destroyed before returning. [2] according to http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2014-March/007290.html

--
Christian Authmann
Philipps-Universität Marburg
Fachbereich Mathematik und Informatik
AG Datenbanksysteme
Hans-Meerwein-Straße
D-35032 Marburg
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to