I've got a numpy ndarray
in three dimensions, saved to disk as a .npy
file. I want to bring it into R to apply some statistical functions that aren't implemented in python. Is there a convenient way to do so? The RcppCNPy doesn't generalize to 3+ dimensions, at least not yet.
I could always save the array in some different format on the python side, but that'd be less convenient and more error-prone.
Here's some dummy data:
import numpy as np
goats_are_super = np.array(list(range(24))).reshape(4,3,2)
np.save("goats_are_super", goats_are_super)
You can try to use reticulate to wrap from R around the existing Python code. This is a little newer, but pretty general supporting many types.
In the RcppCNPy package I have vignette showing how reticulate can do what RcppCNPy does (of course at a cost of potentially slightly more involved installation) so maybe give that a try?
Again, the vignette is here for your perusal.