[R] percent sign in plot annotation

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Jan 17 10:28:13 CET 2007


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/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list