[R] combining mathematical notation and value substitution
Uwe Ligges
ligges at statistik.uni-dortmund.de
Fri Jun 20 09:25:36 CEST 2003
Faheem Mitha wrote:
> Dear People,
>
> I need to make a label which both contains math notation as well as
> substitutes a value for an object. In the following label, len and theta
> are one dim variables, and I am substituting their values appropriately.
> This label looks fine except that I want the greek symbol for theta to
> appear instead of the word `theta'. How can I do so most easily? I don't
> understand the underlying mechanisms well enough to work it out for
> myself. Thanks in advance.
>
> Please cc me. I'm not subscribed to the list.
>
> Faheem.
>
> main=paste("Monotonic Multigamma run (n=",
> deparse(substitute(len)),", ",
> expression(theta),"=", deparse(substitute(theta)),").")
No, it won't work that way, because you have to specify an S expression
in order to get mathematical annotation. An expression within paste()
will be converted to a character string.
What you ca do is the other way round:
t1 <- theta # you cannot use theta as variable and math. symbol
plot(1:10, main =
substitute("Monotonic Multigamma run (" * n == len * ", " *
theta == t1 * ").", list(len = len, t1 = t1)))
See also ?plotmath or that small article in R News:
Ligges (2002): R Help Desk: Automation of Mathematical Annotation in
Plots. R News 2(3), 32-34.
Uwe Ligges
More information about the R-help
mailing list