Re: [R] percent sign in plot annotation

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Wed 17 Jan 2007 - 09:28:13 GMT

On Wed, 2007-01-17 at 09:57 +0000, Martin Keller-Ressel wrote:
> Hello,
>
> I would like to annotate a graph with the expression 'alpha = 5%' (the
> alpha should be displayed as the greek letter).
> I tried
>
> > text(1,1,expression(alpha == 5%))
>
> which gives a syntax error.
> escaping the percent sign (\%) or doubling (%%) does not help.
> What do I do?
>
> Thanks,
>
> Martin Keller-Ressel

Escaping a % with \ and then escaping the \ is not valid syntactically.

This works, but there may be better ways to do this:

plot(0:10, 0:10, type = "n")
text(5,5,expression(paste(alpha == 5, "%", sep = "")))

HTH G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [t] +44 (0)20 7679 0522
ECRC                              [f] +44 (0)20 7679 0565
UCL Department of Geography
Pearson Building                  [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street
London, UK                        [w] http://www.ucl.ac.uk/~ucfagls/
WC1E 6BT                          [w] http://www.freshwaters.org.uk/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
R-help@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.
Received on Wed Jan 17 20:32:23 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 17 Jan 2007 - 10:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.