I can move an array from R to julia without copying the array (with reval) but I was wondering if there is a way to move a julia vector to R without copying the array using RCall. I want to move the vector into a data.table eventually, but moving it to a list should be enough since I can make it into a data.table after that with setDT.
In R <= 3.5, R allocates a single block of memory for the data and metadata, so you’d have to calculate an offset into the pointer to get a data pointer you could pass to julia. In R 3.5, the new “AltRep” data arrangement separates the data and metadata, so you would be able to get a pointer to the data vector. Over at the rjulia package we are considering making use of this. However, the memcopy isn’t all that expensive and doing it protects you from whatever R or julia might do when the object is modified or garbage collected. It might be best just to stick with copying the data.