Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection to memory (R)

Tags:

r

connection

I have to repeatedly serialize (big) R objects. To avoid repeated garbage collecting of the resulting raw vectors (after profiling, it turns out that half of my script running time is spent in gc!) I’d like to ask R to directly write in a memory buffer -- always the same, as after each serialization I’d call a C function with .C that would work directly on this memory buffer; it is the result of this C function that interests me.

Is that possible? How unreasonable is it?

Thanks in advance.

like image 822
Elvis Avatar asked Nov 13 '22 09:11

Elvis


1 Answers

I might not have understood your problem, but why don't you directly use your R object in c++ code using Rcpp. There will be no copy and you don't not need any serialization.

like image 81
Karl Forner Avatar answered Nov 15 '22 05:11

Karl Forner