How can I put the + character in R

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

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

      

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

Just for the future, how about other symbols like Greek letter etc.

+3


source to share


1 answer


I am assuming that you are going to put them in the plot. In this case, be sure to check out the help page ?plotmath

. In your example, you can use

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

      



If you are just using plain text output, it depends on the encoding you configured in your GUI. And how you enter this will depend on your operating system. You can enable the unicode escape code in the string

x<-"Mean \u00b1 SD or N (%)"
Encoding(x)<-"UTF-8"
x
#[1] "Mean ± SD or N (%)"

      

+6


source







All Articles