Make a R script executable by sourcing it in a batch file
Found the answer : I tried to use R interactively via batch mode, which obviously couldn't work as batch is non-interactive.
I nevertheless found a workaround thanks to this answer : https://stackoverflow.com/a/11567220/9765404, consisting in downloading R-Portable with all libraries used by my project installed locally and adding this function to the Rprofile.site file (in App/R-Portable/etc) :
.First = function(){ #.First() is the first function R-Portable will execute when opened
.libPaths(.Library) #force R-Portable to use the local library
source("path-to-file") #launches the program
}
Then you can just export the folder containing R-Portable and your project to any Windows computer and execute R-Portable.exe, it works without having R installed.
how to call an executable from R script
To call any external executables you can use the system
function:
system("cuda_exe arg1 arg2")
where cuda_exe
is the cuda executable, and arg*
are the command line arguments passed to the script.
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.
Related Topics
Automated Formula Construction
Cast String Directly to Idatetime
Extracting Data from Text Files
Error in If/While (Condition):Argument Is Not Interpretable as Logical
Adding Labels on Curves in Glmnet Plot in R
R: Convert Date from Character to Datetime
Text Mining in R | Memory Management
Splitting String Between Capital and Lowercase Character in R
R Shiny Ggplot Bar and Line Charts with Dynamic Variable Selection and Y Axis to Be Percentages
Convergence Error for Development Version of Lme4
How to Split Data Frame by Column Names in R
Using Variable Value as Column Name in Data.Frame or Cbind
Create Combinations of a Binary Vector
Extract Last Non-Missing Value in Row with Data.Table
Documentation for Special Variables in Ggplot (..Count.., ..Density.., etc.)
Filling in a New Column Based on a Condition in a Data Frame
Using Anti_Join() from the Dplyr on Two Tables from Two Different Databases