[Rcpp-devel] Rcpp/C++ serialization of R objects?
Romain Francois
romain at r-enthusiasts.com
Tue Oct 29 16:35:24 CET 2013
Le 29/10/2013 16:24, Rodney Sparapani a écrit :
> Hi Gang:
>
> I have been through the docs, and if this is answered, then I missed
> it. Is there a recommended way to serialize an R object with Rcpp?
Not at the moment. It is pretty easy though to make an R call to saveRDS
using Function ...
Environment base = Environment::base_namespace() ;
Function saveRDS[ "saveRDS" ] ;
List precious = ... // whatever you want to saveRDS
saveRDS( precious, "somefile") ;
> For example, suppose I have created a List in C++ and I want to store
> it with the R equivalent of saveRDS() <because I want to read it in at
> some point later on from within R via readRDS()>.
>
> More details if needed... I am doing some long-running MCMC
> calculations. And, I would like the C++ code to store the
> results every, say, 10000 iterations. Of course, I could do
> this in a loop from R. But, I want to be sure that is really
> necessary before I re-write my R code ;o)
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
More information about the Rcpp-devel
mailing list