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

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri May 30 08:29:17 CEST 2008


I think what you are asking for is not a tilde.  That is a raised symbol 
(an accent), and not as in TeX's $\sim$ .  It is character 126 in the 
Adobe Symbol encoding (Adobe's name is '\similar'), so one way is

expression(X*symbol("\176")*N(mu, sigma^2))

There are others, and in most circumstances

expression(X * "~" * N(mu, sigma^2))

will work.

On Fri, 30 May 2008, 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?

That you don't want a tilde?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list