From ggrothendieck at gmail.com  Fri Apr  4 20:00:23 2008
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Fri, 4 Apr 2008 14:00:23 -0400
Subject: [Rd] __FILE__ for R
In-Reply-To: <f8e6ff050804040850h3e798365ia1ffe299952d6eef@mail.gmail.com>
References: <f8e6ff050804040834k39b7871brd3a3a71de8d3d528@mail.gmail.com>
	<f8e6ff050804040850h3e798365ia1ffe299952d6eef@mail.gmail.com>
Message-ID: <971536df0804041100n3e4cf11ey33e34d962daed9ab@mail.gmail.com>

Although its kludgy this previously (and still works) too:

parent.frame(2)$ofile

if called from top level within a sourced file.

On Fri, Apr 4, 2008 at 11:50 AM, hadley wickham <h.wickham at gmail.com> wrote:
> Sorry, that should be:
>
> FILE <- (function() {
>  attr(body(sys.function()), "srcfile")
> })()$filename
>
> Hadley
>
>
> On Fri, Apr 4, 2008 at 10:34 AM, hadley wickham <h.wickham at gmail.com> wrote:
> > 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/
> >
>
>
>
> --
> http://had.co.nz/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] __FILE__ for R
Gabor Grothendieck