[R] Including a tilde in a plotmath-type call

Charilaos Skiadas cskiadas at gmail.com
Fri May 30 05:25:55 CEST 2008


On May 29, 2008, at 11:02 PM, p_connolly at slingshot.co.nz wrote:

> Suppose I have a plot
> plot(1:10, pch = "")
>
> And I want some text to indicate a Normal distrubition.  I could do
> this:
>
> text(5, 6, substitute(X~~~~N(mu, sigma^2)), adj = 0)
> text(5.35, 6, "~", adj = 0)
>
> But that's clumsy, and depending on your plotting device, might not  
> even look
> sensible.  I'd prefer to be able to do it more directly and
> simply the way these do:
>
> text(5, 1, expression(X %~~% N(mu, sigma^2)), adj = 0)
> text(5, 2, expression(X %prop% N(mu, sigma^2)), adj = 0)
> text(5, 3, expression(X %=~% N(mu, sigma^2)), adj = 0)
>
> They're easy, but they don't give a single tilde.  I know how to put a
> tilde(X) or even a wide tilde, but there're not it either.
>
> What did I miss?
>

Does this do it?

text(2, 3, expression(X *"~"* N(mu, sigma^2)), adj = 0)

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College



More information about the R-help mailing list