When run the following code, I obtain Error in as.graphicsAnnot(text) : could not find function "bold". How can I fix this?
my.qq <- function(x, main=expression(bold(italic(F)~~"Q-Q plot")),
margs=list(side=3, cex=par("cex.main"), font=par("font.main"),
adj=par("adj"), xpd=NA), ...)
{
plot(qnorm(ppoints(n <- length(x))), sort(x), ...)
do.call(mtext, c(list(main), margs))
}
x <- rnorm(100)
my.qq(x)
my.qq(x, main=substitute(bold(italic(F)[N(mu.,s2.)]~~"Q-Q plot"), list(mu.=0, s2.=1))) # fails
My goal is to use the list margs to pass additional arguments to mtext(). That’s normally done with ..., but those arguments are already passed to plot().
substitutein this case returns an language object, not an expression. the expressionexpressionis used loosely inR, however here it appears thatmtextneeds an object of classexpression.You can ensure this by wrapping
substitute(...)inas.expression()or more simply by passing an expression to substitute (as would be required in a normal call to
mtext)Both the examples above will produce

There is a note in the help for
substitutehowever in this case
evalis not required