Re: [R] Using bquote: question

From: Bert Gunter <>
Date: Thu, 24 Jan 2008 19:37:18 -0800

It's a bit subtle, I must admit, but this behavior **is** documented ( ya just gotta read **carefully**).

Your first (S3) plot statement calls plot.default. The "main" argument matches the "main" argument of plot.default and works as you expect, plotting the expression character string that results from paste() using the plotmath functionality.

However, your 2nd plot call calls plot.formula, and the Help for that tells us that the ... argument gets evaluated in the parent.frame(), which in this case is the global environment. But

bquote( paste( p==.(p)," and ",phi==.(phi)) )

in the global environment is just:

paste(p == 2, " and ", phi == 1)
 evaluated in the global environment, and since p==2 and phi==1 are both TRUE there, the paste function becomes
"TRUE and TRUE", which is what you got.

Whether this is "nice" behavior or not I cannot say (because I don't know enough about the ins and outs of computer languages). But I do appreciate that the folks who develop and maintain the core R language do such a careful job of documenting things that even dolts like me can figure it out if we make the effort.

Bert Gunter

-----Original Message-----
From: [] On Behalf Of Schools Statistics Poster Competition Sent: Thursday, January 24, 2008 5:58 PM To: R-help mailing list
Subject: [R] Using bquote: question

Hi all


x <- c(1,2)
y <- c(1,-1)

phi <- 1
p <- 2

par( mfrow=c(1,2))
plot(x , y, main=bquote( paste( p==.(p)," and ",phi==.(phi)) ) ) plot(y ~ x, main=bquote( paste( p==.(p)," and ",phi==.(phi)) ) ) par( mfrow=c(1,2))

On my system (details below), the first plot is correct (in my understanding), and produces a title reading "p=2 and phi=1" (with appropriate Greek for phi).

However, the second produces the title "TRUE and TRUE".

Is this a bug, or a misunderstanding or my part(in which case, I'm sure I'll be told the obscure location where this is documented!)?



> sessionInfo()

R version 2.6.0 (2007-10-03)


attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] tweedie_1.5.3 statmod_1.3.0

loaded via a namespace (and not attached): [1] rcompgen_0.1-15

This email (including any attached files) is confidentia...{{dropped:15}} mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 25 Jan 2008 - 03:42:50 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 Fri 25 Jan 2008 - 07:30:08 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive