[R] trouble with paste()
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Fri Mar 26 23:28:47 CET 2004
"Charles Annis, P.E." <Charles.Annis at statisticalengineering.com> writes:
> Greetings:
>
> I'm trying to annotate a plot and find that I cannot correctly paste
> elements. When I do this:
>
> text(1.4, 1., paste("conditional density", "\n", "of y, given ",
> expression(x == x[0])), adj=c(0.,0.))
>
> The expression is not properly displayed.
>
> Resolving this is not urgent because the workaround is simple:
>
> text(1.4, 1., paste("conditional density", "\n", "of y, given ", sep=""),
> adj=c(0.,0.))
> text(2.3, 0.94,expression(x == x[0]), adj=c(0.,0.))
>
> Still, it'd be more convenient if I could learn to do it correctly.
>
> Any help?
The whole thing needs to be an expression, or you get the consequences
of
> paste("conditional density", "\n", "of y, given ",
+ expression(x == x[0]))
[1] "conditional density \n of y, given x == x[0]"
I think you're looking for
expression(atop("conditional density", paste("of y, given ", x==x[0])))
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list