From: Thomas Lumley (tlumley@u.washington.edu)
Date: Fri 18 Oct 2002 - 03:45:50 EST
Message-id: <Pine.A41.4.44.0210171041120.56050-100000@homer22.u.washington.edu>
On Thu, 17 Oct 2002, [iso-8859-1] Göran Broström wrote:
>
> With the default value of 'labels':
>
> > text(x = c(1, 2), y = 5, labels = seq(along = x))
> Error in seq(along = x) : Object "x" not found
>
> A scoping bug? :)
>
> But
>
> > text(x = c(1, 2), y = 5)
>
> is OK. Doesn't give the labels I want, though. But why does it work, i.e.,
> why is 'x' found in this case and not when I write out the default?
>
Explicit arguments are evaluated in the calling environment and the value
is passed to the function. Default arguments are evaluated inside the
function, so that defaults like seq(along=x) work.
Evaluating explicit arguments inside the function would be a Really Bad
Idea, as you would need to know what variables existed inside the
function.
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:31:25 EST