title: Getting path of an R script
body: <p>Is there a way to programmatically find the path of an R script inside the script itself?</p>
  
  <p>I am asking this because I have several scripts that use <code>RGtk2</code> and load a GUI from a .glade file.</p>
  
  <p>In these scripts I am obliged to put a <code>setwd("path/to/the/script")</code> instruction at the beginning, otherwise the .glade file (which is in the same directory) will not be found.</p>
  
  <p>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:</p>
  
  <p><code>setwd(getScriptPath())</code></p>
  
  <p>So, does a similar function exist?</p>