Compile R script into standalone .exe file?

Is there any easy way to compile my R script into a standalone .exe file just like what Matlab does?

+54
r
Dec 31 '13 at 1:29
source share
4 answers

In fact, there is a way to achieve a solution that meets your requirements. Take a look at the article on deploying Desktop Apps from R to R-Bloggers. As described in detail in the article, you end up using several things besides one exe file.

Also, I would like to draw your attention to RGtk2 using RGtk2, you could try to develop your own interface in R. If the push comes, I hope you can pack your R-code together with the portable version of R and the dependencies in one installer and make and an application that creates the illusion of a single exe file.

In your question, you asked whether it is easy to develop a stand-alone executable that interprets R code. I would not say it easily. If you have a strong desire to run R-code from an application, you can do it in a simpler way using RCaller for Java or R.NET .

+21
Jan 29 '15 at 11:51
source share

In response to your comment:

Actually, I would like to distribute it, but keeping the scripts and algorithm a secret, is there any way to encrypt this or any other way to achieve this?

You can (sort) do this by saving functions with save() . For example, here is the f() function that you want to keep secret:

 f <- function(x, y) { return(x + y) } 

Save it everywhere:

 save(f, file = 'C:\\Users\\Joyce\\Documents\\R\\Secret.rda') 

And if you want to use the function:

 load("C:\\Users\\Joyce\\Documents\\R\\Secret.rda") 

I would save all my functions in separate files, put them in a folder and have one simple old .R script, loading them all and doing anything. Zip it all up and distribute it to anyone. Maybe even compile it into a package. In fact, all this will be read-only.

This decision is not so great. You can still see the function in R by typing the name of the function so that it does not hide in that sense. But if you open .rda files, their contents will be distorted. It all depends on how experienced code recipients have R.

+8
Dec 31 '13 at 9:52
source share

Well, you will need R installed on the deployment machine. Regarding creating an executable, I'm not sure if this is possible. But you can create another program that calls your R script. R is an interpreted language. It's impossible.

+4
Dec 31 '13 at 1:34
source share

One form of encrypted code is implemented in the petals function in the TeachingDemos package.

Please note that searching for hidden code only requires programming skills at the intermediate level, however, it makes a focused effort and the user will not be able to require that he accidentally see the code. Then you will need some type of license agreement to enforce any contractual agreements.

+4
Dec 31 '13 at 19:03
source share



All Articles