[R] Using bquote: question

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Jan 25 05:41:56 CET 2008


On 1/24/08, Bert Gunter <gunter.berton at gene.com> wrote:
> I should have perhaps phrased my previous post better as: the result of
> bquote() is a language expression argument of mode "call" which gets
> evaluated by the plotmath functionality in your first plot call, but  gets
> evaluated in the global environment in the second before being passed back
> to the plot.default method that will be called by plot.formula to do the
> plot.

Right, and the solution is to coerce to expression explicitly:

plot(y ~ x, main=as.expression(bquote( paste( p==.(p)," and ",phi==.(phi)))))

-Deepayan

> -- Bert Gunter
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] 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
>
> Observe:
>
> 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!)?
>
> Thanks.
>
> P.
>
>
> > sessionInfo()
> R version 2.6.0 (2007-10-03)
> i486-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8
> ;LC_MONETARY=en_AU.UTF-8;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAM
> E=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION
> =C
>
> 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}}
>
> ______________________________________________
> 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.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list