On 22 Nov 2013, at 07:53 , Rolf Turner <r.tur...@auckland.ac.nz> wrote:
> On 11/22/13 18:47, William Dunlap wrote: >>> a <- 2; b <- 3; xyplot(1:10 ~ a*(1:10), sub = c(bquote(a == .(a) ~ >>> b==.(b)))) >>> >>> the subtitle contains three copies of the "a = 2 b = 3" phrase. >>> Why does it do that? How do I tell it to give me only one copy? >> To avoid it don't wrap bquote() with c(). The following does what you asked >> for: >> a <- 2; b <- 3; xyplot(1:10 ~ a*(1:10), sub = bquote(a == .(a) ~ >> b==.(b))) > > Not for me it doesn't. Without the c() wrapper, I get no subtitle at all. > Your recipe seems to > work with base graphics and plot() but not with lattice and xyplot(). Also > the c() wrapper > seems to have no impact when used with plot(). > > Moreover I am mystified by the impact of the c() wrapper when used with > xyplot(). > > The result returned by bquote() has class "call". The result returned by > c(bquote(...)) is a > list, of length 1, whose sole entry is of class "call" and is, as one might > expect, equal to the > result returned by bquote(). > > But why should passing this length-1 list as the value for "sub" cause a > triplication of the > subtitle? I dunno either, but a hint at the reason would be to look at what happens with xyplot(0 ~ 1, sub=list(quote(1+1))) When you do computing on the language, sometimes quote()’ing is not sufficient protection against evaluation. That’s what expression objects are for. A solution seems to be xyplot(0 ~ 1, sub=as.expression( bquote(pi==.(pi) ~ e==.(exp(1))) )) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@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.