How can I type the +- symbol in R

13,145

I'm assuming you're going to be putting these on a plot. If that's the case, then be sure to check out the ?plotmath help page. In your example, you could use

plot(1,1,main=expression(paste("Mean", phantom(.)%+-%phantom(.), "SD or N (%)")))

If you're just taking about plain text output, that depends on the encoding you have set up on your GUI. And how you type that in would depend on your operating system. You can include the unicode escape code in a string

x<-"Mean \u00b1 SD or N (%)"
Encoding(x)<-"UTF-8"
x
#[1] "Mean ± SD or N (%)"
Share:
13,145
wen
Author by

wen

Updated on June 25, 2022

Comments

  • wen
    wen about 2 years

    I need to use a heading that includes Mean +- SD. So far, I can only get this:

    "Mean +- SD or N (%)"
    [1] "Mean +- SD or N (%)"
    

    How can I directly use the "+-" symbol? You know the one character, not two.

    Just for the future, how about other symbols, like Greek letter and so on?