Skip to content
Prev 33600 / 398506 Next

combining mathematical notation and value substitution

On Fri, 20 Jun 2003, Faheem Mitha wrote:

            
That's only part  of the expression. This is the full expression
"Monotonic Multigamma run (" * n  == len * ", " *  theta == t1 * ")."

Now, this looks very strange, but if it looked like
   a* n==len * b * theta==t1 * d
it would be a perfectly reasonable  product of five terms,  two of which
are logical expressions.  I think in fact that it is a call, not an
expression, but in this case it doesn't matter.

In Uwe's example a, b, and d were strings.  The expression is still
lexically valid, but it can't be evaluated any more. That's ok, since it
isn't supposed to be evaluated.

What you can use in the mathematical annotation functions is parsed but
unevaluated R code.  You can get this mostly easily as the output of
quote(), expression() or substitute().

  quote("Parameter " * theta==1)
  expression("Parameter " * theta==1)
  substitute("Parameter " * theta==t, list(t=1))

For the purposes of mathematical annotation these are all equivalent,
though the second returns an `expression' and the other two return a
`call'.

The second form is occasionally needed, as in
  legend(locator(1), lty=1:2, legend=expression(alpha,beta))
which I don't think you can do any other way.

You can think of an expression as a vector of calls, so
expression(alpha)
alpha

which is what the manual was trying to say (I think). Much of the time you
can ignore the difference between `call' and `expression' objects.


	-thomas