4

I'm trying to write the << symbol in R but I'm not succeeding. Any tips?

plot(expression(alpha<1))

enter image description here

plot(expression(alpha<<1))

Error: unexpected input in "plot(expression(alpha<<"
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38

2 Answers2

5

Using unicode

plot(1, 1, xlab = bquote(alpha~"\u226A"~1))
akrun
  • 874,273
  • 37
  • 540
  • 662
  • why does "bquote" change the behaviour of unicode in the plot window compared to just plain unicode? Eg; `plot(1:3, main = '\u226A')` gives me a fine little square, while adding bquote fixes it right up. – Oliver Jul 27 '21 at 19:10
  • @Oliver It may be an issue related to the encoding settings in your system – akrun Jul 27 '21 at 19:11
  • `bquote` changes the behavior of `alpha`, as far as I can tell not of the unicode character. @Oliver might be having a missing (not installed) fonts problem. – Rui Barradas Jul 27 '21 at 19:14
  • It's interesting as `'\u226A'` works fine in the console, but fails in the plot window. Windows OS problems maybe. – Oliver Jul 27 '21 at 19:16
  • 1
    I think you may find that `bquote` forces use of the Symbol font, whereas you get the default font when it's not clearly intended as `expression`-class. – IRTFM Jul 27 '21 at 21:24
  • Note that the plot method being called seems to be different than base graphics: `plot(expression(alpha<1))` gives `Error in xy.coords(x, y, xlabel, ylabel, log) : invalid first argument` – IRTFM Jul 27 '21 at 21:32
2

This is the closest I am so far, how does this work for you?

plot(
        x = 1:10,
        y = 1:10,
        main = expression(paste(alpha, "<<", 1))
)
Serkan
  • 1,855
  • 6
  • 20