Compile R Script into Standalone .Exe File

Creating an executable R-file

The tutorial you gave is useful. However, it missed something.
After done all the things in that blog, you still need to do one more thing. Right click on the "test.Rexec" file and choose "open with" and then select "RScript". Maybe you need to find RScript in your system which is usually here:

C:\Program Files\R\R-3.2.1\bin\Rscript.exe

Remeber to check the "Always use the selected program to open this kind of file".
Next time, when you double click the "test.Rexec" file, evethying would be okay.

Is it possible to compile R scripts into a binary?

Found this: I'm not sure about the security, but this is definitely a deterrent and would take (I think) some fairly concentrated effort to crack. There is a byte code compiler for R based on the paper linked below. There is a method in library(compiler), which comes standard with R, that allows you to compile an R script to byte code. In the same library, you can load in the source files and use them as you'd like.

A Byte Code Compiler for R

Installing executable scripts with R package

Short (and very sad) answer: You cannot. But read on.

Reasoning: R will only ever write package content to its own .libPaths() directory (or the first in case several are given), or a directory given by the user.

So, say, /usr/local/bin/ is simply out of reach. That is a defensible strategy.

It is also rather sad--I wrote littler (also CRAN page) for exactly this purpose: executable R scripts. And we have dozens of those at work called from cron jobs. So what do we do? A one-time soft-link from the scripts/ subdirectory of the package containing the script to /usr/local/bin. At package upgrades, the link persists as a soft-link.

And that's what I do for e.g. all the examples shipping with littler and more from other packages. Many of them use docopt too.



Related Topics



Leave a reply



Submit