0

I have a batch file with the following code:

mybat.bat

cd "%~dp0"
"C:\Program Files\R\R-3.4.2\bin\i386\Rterm.exe" --no-restore --no-save 
 < app.r > "shiny.log" 2>&1

The path to R is hardcoded and it runs well executing my 'appr.r' script. However, I would like to use a dynamic path to R because R might be on a different directory depending on which laptop I am using. My question is: is it possible to get the relative path of R in a batch file? I have some code that I use in an R script to find the relative path to R but I am not able to implement it in a batch file. How can I use the following code in a batch file to find the path to R?:

system2(paste(R.home("bin"), "/R", sep=""), args="CMD BATCH app.r 
shiny.log")
Community
  • 1
  • 1
Salvador
  • 1,229
  • 1
  • 11
  • 19
  • check this path https://stackoverflow.com/questions/12048436/r-sourcing-files-using-a-relative-path – vivek g Dec 11 '17 at 05:51
  • I checked that post earlier but it doesn't work for me because is all R code on an R script. I need R code to work inside my batch file. I wonder if someone can make this work in the batch file: system2(paste(R.home("bin"), "/R", sep=""), args="CMD BATCH app.r shiny.log") – Salvador Dec 11 '17 at 06:00

0 Answers0