Re: [R] File > Save As...

From: Hadley Wickham <hadley_at_rice.edu>
Date: Wed, 16 Mar 2011 08:06:09 -0500

> No, defaults are evaluated in the evaluation frame of the function. That's
> why you can use local variables in them, e.g. the way rgamma uses 1/rate as
> a default for scale.

Oops, yes, I was getting confused with promises - non-missing arguments are promises evaluated in the parent frame.

> But the point isn't evaluation here:  the point is the parsing.  A function
> gets its source attribute when it is parsed, so getSrcFilename needs to be
> passed something that was parsed in the script.

Still, it would be nice to have a function that, by default, would return the location of the calling script. You can also hack something together using sys.frames(), but it would be nice to have official R support for it.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 16 Mar 2011 - 13:21:40 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 Wed 16 Mar 2011 - 13:30:22 GMT.

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

list of date sections of archive