Is there a way to programmatically find the path of an R script inside the script itself?
I am asking this because I have several scripts that use RGtk2
and load a GUI from a .glade file.
In these scripts I am obliged to put a setwd("path/to/the/script")
instruction at the beginning, otherwise the .glade file (which is in the same directory) will not be found.
This is fine, but if I move the script in a different directory or to another computer I have to change the path. I know, it's not a big deal, but it would be nice to have something like:
setwd(getScriptPath())
So, does a similar function exist?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…