Re: [Rd] ?bquote

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat 11 Feb 2006 - 02:05:39 GMT

On 10 Feb 2006 12:15:10 +0100, Peter Dalgaard <p.dalgaard@biostat.ku.dk> wrote:
> Gabor Grothendieck <ggrothendieck@gmail.com> writes:
>
> > ?bquote says it returns an expression but, in fact, it typically
> > (though not always) returns a call object:
> >
> > > class(bquote(a+b))
> > [1] "call"
> >
> > > class(bquote(1))
> > [1] "numeric"
>
> Unevaluated expressions and objects of mode "expression" are not the
> same thing. The latter is effectively a list wrapping one or more of
> the former.
>
> Unevaluated expressions are generally mode "call", except when they
> are constants. They do, however, correspond to expressions as
> syntactic element (look for "expr" inside gram.y in the sources).
>
> The terminology does not seem completely rationalised, see also the
> help pages for expression() and substitute()/quote(), and it might be
> worth cleaning it up at some point. Just requires someone with a
> sufficiently clear mind to decide on issues like whether constants
> qualify as "unevaluated calls"... (my hunch is that they don't, and
> that "unevaluated expressions" should be used throughout, but my mind
> is definitely not clear these days.)
>
> Another question is whether it would be desirable for bquote to return
> an "expression" object. I realized recently that
>
> > boxplot(rnorm(99),ylab=quote(a[1]))
> Error in title(ylab = a[1]) : object "a" not found
>
> and that you need expression(a[1]) instead. I think this implies that
> you'd have to use as.expression(bquote(....)) which is a bit nasty.
> I'm not sure this isn't a bug in boxplot, though.

I think this is the same issue that Berton Gunter brought up on r-help recently with

   x <- y <- 1:10
   plot(y ~ x, main=quote(abc))

which gives an error message even though

   plot(x,y,main=quote(abc))

does not.

The first case seems to be stripping off one layer so that

   plot(y ~ x, quote(quote(abc)))

is ok but just one quote is not.



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Feb 11 13:07:32 2006

This archive was generated by hypermail 2.1.8 : Mon 13 Feb 2006 - 14:59:18 GMT