[R] Paste symbol and calculation in plot
Jonathan R. Blaufuss
blaufusj at carleton.edu
Tue Aug 11 23:30:00 CEST 2009
Thanks! That works great. I appreciate the help.
----- Original Message -----
From: "Scott Sherrill-Mix" <shescott at mail.med.upenn.edu>
To: "Jonathan R. Blaufuss" <blaufusj at carleton.edu>
Cc: r-help at r-project.org
Sent: Tuesday, August 11, 2009 4:18:18 PM GMT -06:00 US/Canada Central
Subject: Re: [R] Paste symbol and calculation in plot
I'm no expert at this but it seems like ?plotmath is saying to do
Department of Microbiology
University of Pennsylvania
402B Johnson Pavilion
3610 Hamilton Walk
Philadelphia, PA 19104-6076
On Tue, Aug 11, 2009 at 4:00 PM, Jonathan R.
Blaufuss<blaufusj at carleton.edu> wrote:
> I'm trying to annotate a density plot and I would like to have R calculate the
> standard deviation and place it in the plot next to the standard deviation symbol
> "sigma". I can successfully use the text command to paste "StDev =",round(sd(Data),digits=3))
> on the plot. However, I have trouble when I want to replace "StDev" with the Greek
> symbol sigma (See code below).
> text(2,0.35,paste("StDev =",round(sd(Data),digits=3)))
> Through searching the help files I figured out that I can paste the sigma symbol on the
> plot using the command "expression".
> text(2,0.3,expression(paste(sigma," = 0.898")))
> However, when I try to paste together the sigma symbol and the standard deviation
> that R is calculating, the text of the command to calculate the standard deviation
> shows up on the plot instead of the number which I am asking it to calculate.
> text(2.2,0.25,expression(paste(sigma," = ",round(sd(Data),digits=3))))
> Can someone please point me to a resource that will help me figure this out?
> Thank You,
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help