Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text() to display a greek letter with subscript in R plot

Tags:

plot

r

I was wondering how I could make the letter "sigma" appear in Greek with the subscript "m" in the text() part of the R code below?:

curve(dnorm(x,175.3,.961),160,190,type="l")

sigmam <- dnorm(177.4,175.3,.961)/ dnorm(177.4,176,4)

text(165,.285,paste("sigmam", "=", round(1/sigmam,digits=2)))
like image 367
rnorouzian Avatar asked Dec 18 '16 22:12

rnorouzian


People also ask

How do you write a subscript in R plot?

Subscripts and Superscripts To indicate a subscript, use the underscore _ character. To indicate a superscript, use a single caret character ^ . Note: this can be confusing, because the R Markdown language delimits superscripts with two carets.

How do I put Greek letters in R?

To make a Greek letter in R, You just use \ and then the name of the letter. If you want a subscript, like β1 , you use $\beta_1$ .

How do I code MU in R?

You may want to include math like greek symbols, etc., in your R Markdown documents. In this class, this is totally optional. If you want a μ in your document, you can just type “mu” instead and forget about the extra complication.


1 Answers

Check out ?plotmath for relevant examples of how to piece this sort of thing together. For instance, here's one adapted from the "## How to combine "math" and numeric variables :"

curve(dnorm(x,175.3,.961),160,190,type="l")
sigmam <- dnorm(177.4,175.3,.961)/ dnorm(177.4,176,4)

text(165,.285, bquote(Sigma[m] == .(round(sigmam,2))))

enter image description here

like image 182
thelatemail Avatar answered Oct 02 '22 11:10

thelatemail