Search code examples
rosx-mountain-lionplotmath

Substitute not displaying text on plots


I just recently learnt about plotmath and its ability to put mathematical expression in text on plots.

However I'm encountering some strange behaviour where the substitute function does not render any text.

Here's a simple case that should work (from this answer):

labNames <- c('xLab','yLab')
plot(c(1:10),
     xlab=substitute(paste(nn, x^2), list(nn=labNames[1])),
     ylab=substitute(paste(nn, y^2), list(nn=labNames[2])))

When I run this code snippet, there is no xlab or ylab text.

I'm running mac osx and R 3.0.0. This problem persists whether i output to Quartz or to a png file.

Here's my sessionInfo():

R version 3.0.0 (2013-04-03)
Platform: x86_64-apple-darwin12.3.0 (64-bit)

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base        

Solution

  • I found the culprit: there was a weird interaction with an option in my .Rprofile

    The following line causes the issue if i don't load the devtools package:

    options(devtools.desc.author="'Scott Ritchie <sritchie73@gmail.com> [aut, cre]'")

    Strangely, there doesn't seem to be an issue if i define other irrelevant options (options(notanoption=TRUE) caused no issues).