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). 

        set.seed(1)
        Data=rnorm(100)
        plot(density(Data))
        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,

Jonathan

______________________________________________
R-help@r-project.org 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.

Reply via email to