Here is an example:
PMEx <- function(t) {
y <- (1:10)^2
plot(1:10,y,type="l")
text(2,90,label="This is NOT what I want -->",adj=0)
text(2,80,label="This IS what I want -->",adj=0)
text(2,70,label="This is NOT what I want -->",adj=0)
# --- These are representative lines of code ---
text(5,90,label=expression("x[0]")) # This is NOT what I want
text(5,80,label=expression(x[0])) # This IS what I want
text(5,70,label=expression(t)) # This is NOT what I want
} # End of PMEx().
RunPMEx <- function() {
PMEx("x[0]")
} # End of RunPMEx().
RunPMEx()
This code generates a plot with text lines, one showing what I want (the letter x with subscript 0) and two others showing what happens (NOT what I want) when expression() is used. I have tried various suggestions in Stack Overflow, but none of them work in this case (e.g. using bquote(.(t)), paste, parse, substitute). The last text(...) line of PMEx(t) is a prototype for what I want.