2

I want to add the symbol in to a legend in R as in

..."≤1",col="gray"...

but when I run the script it creates and = symbol as if I have typed

..."=1",col="gray"...

Is there a way I can tell R I want that ≤ symbol?

And to help anyone with a similar problem; is there a list of commands that can be used to tell R how to add unusual characters?

plannapus
  • 18,529
  • 4
  • 72
  • 94
rg255
  • 4,119
  • 3
  • 22
  • 40

1 Answers1

3

Thanks to @agstudy for pointing me in the right direction, took a little tweaking but got there with this:

   legend(...expression(""<="1.0"),col="gray"...)

More symbols can be found in the using ?plotmath (see here) and are implemented using expression()

Here is an example:

enter image description here

x <- 0:64/64
y <- sin(3*pi*x)
plot(x, y, type= "l", col= "blue",
     main= expression("How to add the symbol"<="to a legend"))
points(x, y, pch= 1, bg= "white")
legend(.4,1, expression(""<= "1.0"), pch= 1, pt.bg= "white", lty= 1, col= "blue")
rg255
  • 4,119
  • 3
  • 22
  • 40
  • @agstudy I can't accept a self answer for two days, if you copy this in to a new answer I'll delete this one and accept & upvote yours – rg255 Jun 26 '13 at 13:39
  • Ok, thanks for the help finding the solution & adding the example to the answer – rg255 Jun 26 '13 at 13:49