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%))Try text(1,1,expression(alpha == 5*"%")) Best, Bettina
you can try text(1, 1, expression(paste(alpha, " = 5%"))) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Martin Keller-Ressel" <mkeller at fam.tuwien.ac.at> To: <r-help at stat.math.ethz.ch> Sent: Wednesday, January 17, 2007 10:57 AM Subject: [R] percent sign in plot annotation> 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 > > > > -- > Martin Keller-Ressel > Research Unit of Financial and Actuarial Mathematics > TU Vienna > > ______________________________________________ > R-help at 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. >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
On Wed, Jan 17, 2007 at 09:57:49AM -0000, Martin Keller-Ressel wrote:> 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%))text(1,1, expression(paste(alpha == 5, '%')) ) cu Philipp -- Dr. Philipp Pagel Tel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel
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-ResselEscaping 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/ %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
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 -- Martin Keller-Ressel Research Unit of Financial and Actuarial Mathematics TU Vienna
Thanks to Bettina, Dimitris and Gavin for their help. All their solutions work nicely. For future reference, here are three ways to draw a percent sign in R plots: plot(0:10, 0:10, type = "n") text(5,7,expression(paste(alpha == 5, "%", sep = ""))) text(5, 5, expression(paste(alpha, " = 5%"))) text(5,3,expression(alpha == 5*"%")) best regards, Martin Keller-Ressel -- Martin Keller-Ressel Research Unit of Financial and Actuarial Mathematics TU Vienna