I need to share my data and R source files with a coworker who doesn't have any experience with command line. Moreover, I work in Linux while she's under Windows. But she would like to change some constants and recalculate the scripts. So, it would be cool if she could just double click the R source file and R will be executing in the same directory where the source and data files lie. I thought about setting
Rscript -e "source(\"%1\",chdir=TRUE)"
to the association key in the registry, but the filename (%1)
will contain backslashes which R will not handle.
Another way is to setwd()
to the source directory in the beginning of my script, but I don't know how to obtain it. AFAIK, argv[0]
will be R.exe
, not the source.R
.
Using GUI is not very convenient, either, because it requires to separately change directory and then to load the script.
Do I have to write a R loader (exe or cmd) for this?