1

In order to write Greek letters / math on plot axes, we can use expression(alpha). Is this the same as an unevaluated expression, as defined here? I don't see the connection between the two. Shouldn't expression(alpha) returns the unevaluated expression alpha? How did it become the symbol $\alpha$?

Community
  • 1
  • 1
Heisenberg
  • 8,386
  • 12
  • 53
  • 102
  • 1
    An `expression` is really just a special list of language objects or calls. So if you want to just get `alpha`, use `expression(alpha)[[1]]`. The plotmath stuff chose to implement its syntax using expressions. I suppose they could have required strings or formula or lists or something else. I'm not sure what type of connection you expect. – MrFlick Sep 03 '14 at 04:47
  • So is the `expression(alpha)` that I feed to plotmath the same kind of (unevaluated) expression? Or are they two different things with the same name? That's what I'm trying to understand. Plus, if they are the same then how do we get from `expression(alpha)` to the symbol $\alpha$ on the plot? – Heisenberg Sep 03 '14 at 04:50
  • 1
    They are the same thing. Translating those expressions into shapes on a plot is done in C code by the graphics engine. You could read the [plotmath.c](https://github.com/wch/r-source/blob/fbf5cdf29d923395b537a9893f46af1aa75e38f3/src/main/plotmath.c) source or maybe the [GraphicsEngine.h](https://github.com/wch/r-source/blob/fbf5cdf29d923395b537a9893f46af1aa75e38f3/src/include/R_ext/GraphicsEngine.h) file to get some idea how the code works. – MrFlick Sep 03 '14 at 04:59

1 Answers1

1

No. This returns just alpha:

quote(alpha)

An expression vector should be thought of as a type of list. The plotmath interpreter is set up to be a plotting subset of something like LaTeX, but in a much more limited way. Review these pages:

 ?plotmath # really need to work through the examples; one by one
 ?bquote   # exceedingly useful ...  except with lattice functions
 ?substitute   # several of the plotmath examples need `substitute`
 ?points   # the example at the end.
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • What specifically are you saying "no" to? Because `quote(alpha)==expression(alpha)[[1]]`. So you're just reinforcing the notion that `expression()` is a container? – MrFlick Sep 03 '14 at 05:06
  • That's my understanding. `list(a)` is not the same as `a`, just as `expression(alpha)` is not the same as `quote(alpha)`. – IRTFM Sep 03 '14 at 06:33