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
Adding New Columns to a Data.Table By-Reference Within a Function Not Always Working
Fill Region Between Two Loess-Smoothed Lines in R with Ggplot
Include Space for Missing Factor Level Used in Fill Aesthetics in Geom_Boxplot
No Rtools Compatible with R Version 3.5.0 Was Found
Is There a Vectorized Parallel Max() and Min()
Writing Multiple Data Frames into .CSV Files Using R
How to Add Multiple Columns to a Data.Frame in One Go
Determining Utm Zone (To Convert) from Longitude/Latitude
Can Dcast Be Used Without an Aggregate Function
Extract Last Word in String in R
Rgdal Installation Failed on Ubuntu 16.04
Libstdc++.So.6: Version 'Glibcxx_3.4.26' Not Found on Linux
Command to See 'R' Path That Rstudio Is Using
Alternative to R's 'Memory.Size()' in Linux
How to Plot a Stacked and Grouped Bar Chart in Ggplot
Colour Points in a Plot Differently Depending on a Vector of Values