Possible Duplicate:
Rscript: Determine path of the executing script
Always I run an R script, it take My Documents
as working directory.
When I run the script, I want to get the script path and change the working directory to it. How I can do this?
I want this to run the scripts in same folder with the source()
function.
args <- commandArgs(trailingOnly = F) ; scriptPath <- dirname(sub("--file=","",args[grep("--file",args)]))
From one of the answers in the above cited SO link. – Rigmarole