[R] help with pasting + expressions?

Gabor Grothendieck ggrothendieck at gmail.com
Thu Aug 24 05:45:55 CEST 2006


Try bquote:

y.hat <- sigma.hat <- 1.1
plot(1)
lab <- bquote(hat(y) == .(y.hat) * "," ~ hat(sigma)^2 == .(sigma.hat))
text(1, 1, lab, pos = 4)


On 8/23/06, Jeff D. Hamann <jeff.hamann at forestinformatics.com> wrote:
> I can't believe I'm having such a hard time with this and I haven't been
> able to find out how to solve this...
>
> lab <- expression( paste( hat(v),
>    as.character(round(y.hat,2)), ",",
>    hat(sigma)^2, as.character(sigma.hat)) )
> text( x=pt$x+2, y=pt$y,labels=lab )
>
> ## the text should be \hat{y} = <value of y.hat>, \hat{\sigma}^2 == <value
> of sigma.hat>
>
> and R keeps displaying the actual text of the non-expressions...
>
> I must be a chowderhead, but I need a little guidance, please...
>
> Thanks,
> Jeff.
>
>
> --
> Forest Informatics, Inc.
> PO Box 1421
> Corvallis, Oregon 97339-1421
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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