Tuesday, August 11, 2009

Sophisticated axis labels in R

Sometimes you need to put Greek letters or simply a sub index in an axis label of a plot. You could do the following:
xlab=expression(paste("US Markets",~~(omega[kt]),sep=""))
where omega is, well, omega, and [kt] will put a subindex kt. It works for ylab, main, etc.


  1. One "problem" I have been having with this is that I can not quite have subscripts or superscripts and/or when I have to alternate between text and numbers... After some trial and error I usually get it... Do you have some nice intuition on that?

    P.S. let me know if you need an English translation of the above :)

  2. Anonymous, try this:

    paste("US Markets",~~(omega[kt])," and",~~(beta[kt]^1),sep="")
    It should give you the superscripts combined with the subscripts and also text in between them.

    Hope it helps