[Rd] __FILE__ for R

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri, 04 Apr 2008 10:34:30 -0500


I've often missed the ability to get the directory of the currently running script. It's actually been possible for a while:

FILE <- (function() {
  attr(body(sys.function()), "srcfile")
})()

thanks to Duncan's recent changes to file parsing. This is pretty useful for sourcing in files relative to the current script, rather than the working directory.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 04 Apr 2008 - 15:39:26 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Apr 2008 - 17:31:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive