Re: [Rd] ?bquote

From: Peter Dalgaard <>
Date: Fri 10 Feb 2006 - 11:15:10 GMT

Gabor Grothendieck <> 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.

   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (                  FAX: (+45) 35327907

______________________________________________ mailing list
Received on Fri Feb 10 22:46:10 2006

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:41 GMT