[R] Paste symbol and calculation in plot

Jonathan R. Blaufuss blaufusj at carleton.edu
Tue Aug 11 22:00:22 CEST 2009

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,


More information about the R-help mailing list