[R] plus/minus +/- in factor; not plotmath not expression
David Winsemius
dwinsemius at comcast.net
Mon Dec 2 22:22:26 CET 2013
On Dec 2, 2013, at 1:01 PM, Duncan Murdoch wrote:
> On 02/12/2013 2:22 PM, Jacob Wegelin wrote:
>> I want to put the "plus or minus" symbol into a character variable, so that this can be turned into a factor and be displayed in the "strip" of a faceted ggplot2 plot.
>>
>> A very nice solution, thanks to Professor Ripley's post of Nov 16, 2008; 3:13pm, visible at http://r.789695.n4.nabble.com/Symbols-to-use-in-text-td874239.html and subsequently http://www.fileformat.info/info/unicode/char/00b1/index.htm, is:
>>
>> junk<- "\u00B1"
>> print(junk)
>>
snipped
>> Is there a "native R" way to do this?
>
> That is native R.
There is also plotmath's '%+-%' operator:
plot(1,1, ylab = expression( A %+-% B ), xlab=expression( C%+-% D ) )
I noticed that Jacob was using ggplot2. Generally one can eventually find ways to label ggplot2 output with R expressions (used in the strict R language sense of the word), although sometimes it has been difficult for me to find the methods in the help pages.
--
David.
>
> Duncan Murdoch
>>
>> I did this in:
>>
>> > sessionInfo()
>> R version 2.15.3 (2013-03-01)
>> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>>
>>
>>
>> Incidentally (and for the sake of keyword searches): Although a google search initially led me to posts about expression() and plotmath, those eventually had nothing to do with the solution.
>>
>> Jacob A. Wegelin
>
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list