Cited from An R bquote example
When a plot is annotated with mathematics symbols in R, the use of expression may be required.
For example,
text(0, height[2], labels=expression(Y[med] ~ "=" ~ B*x^2), cex=3).
Contents surrounded by square ("[" and "]") brackets appear in subscript.
The tilde "~" operates as a separator, and does not show up in a plot.
If we wish to introduce variables in the annotation along with the mathematics symbols, the bquote function may be used.
For example,
text(0, height[i], labels=bquote(Y[.(z2[i])] ~ "=" ~ .(z1[i])*x^2), cex=3)
.(variable_name) retrieves the value stored in the variable and place the value inside the expression.
No comments:
Post a Comment