I would like to get the latex symbol for beta with a subscript of 2.
The following code:
idx <- 2;
ylab(eval(expression(paste("beta[",idx,"]",sep=""))))
produces the label “beta[2]” instead of “\beta_{2}”. What am I doing wrong?
Note: to see what I want, just use ylab(expression(beta[2])), but I want to pull the value out of the variable idx instead of using a hard-coded value.
Use bquote. Here is a sample code snippet