# Re: [R] Question about 'text' (add lm summary to a plot)

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat 23 Jul 2005 - 03:16:28 EST

On 7/22/05, Thomas Lumley <tlumley@u.washington.edu> wrote:
> On Fri, 22 Jul 2005, Dan Bolser wrote:
>
> > On Fri, 22 Jul 2005, Gabor Grothendieck wrote:
> >
> >> Try as.expression(bquote(...whatever...))
> >
> > Sob, wimper, etc.
>
> a<-7
> plot(1)
> legend("topleft",legend=do.call("expression",
> list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1)))))
>
> works for me. The trick is getting the inner calls to bquote
> evaluated, since expression doesn't evaluate its argument.

I think legend accepts a list argument directly so that could be simplified to just:

a<-7
plot(1)
L <- list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1)))   legend("topleft",legend=L)

The same comment seems to apply to my prior suggestion about as.expression(bquote(...)), namely that one can just write the following as text also supports a list argument:

```my.slope.1 <-   3.22
my.slope.2 <-   0.13
my.inter.1 <- -10.66
my.inter.2 <-   1.96

```

plot(1:5)
L <- list(
"Intercept:", bquote(.(my.inter.1)%+-%.(my.inter.2)),   "Slope:", bquote(.(my.slope.1)%+-%.(my.slope.2)) )
text(2, c(4,4,4.25,4.25), L, pos = c(2,4,2,4))

R-help@stat.math.ethz.ch mailing list