Wishlist-for-R icon indicating copy to clipboard operation
Wishlist-for-R copied to clipboard

Something like Cython

Open RobertMyles opened this issue 4 years ago • 6 comments

...is this even possible? Totally not an expert on these things, and apologies if it's been brought up elsewhere (couldn't find it).

Had some colleagues who were open to using R for some task (apologies, can't remember now, this was some months ago) but needed something like Cython. I see it mentioned here on RStudio Community, but with no responses.

Thanks!

RobertMyles avatar Jun 30 '20 13:06 RobertMyles

You can easily call C or C++ code from R, lots of packages do that. You still need to write a wrapper function that translates R objects to C/C++ objects and back, so it is not as automatic as Cython, but very workable, still.

It would be very possible to create the calls dynamically with something like libffi, there used to be a package on CRAN for this, actually: https://github.com/cran/rdyncall This would actually make things slower, because dynamically assembling calls to C/C++ takes time. The current system works well enough, so nobody really bothered with this so far.

gaborcsardi avatar Jun 30 '20 13:06 gaborcsardi

Hi Gabor, Thanks for your input! Sorry, I didn't make myself clear, I was more thinking of compiling R code into an executable, which I believe (perhaps I'm wrong) is possible for Python code with Cython. In other words, I'd have an .exe of R code, or something along those lines.

RobertMyles avatar Jun 30 '20 13:06 RobertMyles

In that case, you can try the RInside package.

gaborcsardi avatar Jun 30 '20 13:06 gaborcsardi

Hi @gaborcsardi ,

Actually I was thinking the same thing: to make my R codes into a standalone .exe and just sent to my colleagues and run everywhere on Windows. I think what most ppl (incl myself) looking for is to convert R codes into .exe without rewriting most of the scripts.

I do many Google search, and only got python solution as in pyinstaller

Was hoping for a equivalent of pyinstaller in R

jonekeat avatar Jul 08 '20 03:07 jonekeat

@jonekeat For Windows, maybe this could work for you? https://github.com/wleepang/DesktopDeployR

RobertMyles avatar Jul 18 '20 09:07 RobertMyles

@RobertMyles I saw this project before, it is good for deploy apps using shiny or graphical interfaces, if I am doing shiny and wanted to deploy locally, I think RInno seem to be a better choice.

But if we are talking just R scripts without UI, cant think of any ways to make it standalone executable like pyinstaller

jonekeat avatar Jul 23 '20 13:07 jonekeat