[R] ggtern and bquote...
Martin Maechler
maechler at stat.math.ethz.ch
Mon Dec 4 15:16:00 CET 2017
>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>> on Mon, 4 Dec 2017 14:55:19 +0100 writes:
>> On 4 Dec 2017, at 11:58 , Levent TERLEMEZ via R-help
>> <r-help at r-project.org> wrote:
>>
>> Dear Users,
>>
>> What is the proper way to write symbol, superscript,
>> subscript in ggtern/ggplot? I tried every given example,
>> every possible features of ggplot but couldn’t achived. I
>> just want to write P_a, sigma^2, etc, would you please
>> advise me about this problem.
> Did you try expression(P_a)? I don't do much gg-stuff, but
> I seem to recall that quote() doesn't quite cut it the way
> it does in base graphics.
> -pd
Yes, I vaguely remember that indeed also for the lattice package
(which is based on 'grid' the same as 'ggplot2' is ..) sometimes
expressions instead of calls are needed, i.e., expression(*)
instead of just quote(*).
However, I think Levent really meant what you'd get by
expression(P[a]) ?
@Levent: The clue is the need for valid R syntax, and indeed, as
in LaTeX x_i often is the i-th element of x, the R syntax for
indexing/subsetting is used here, i.e.
x[i] for LaTeX x_i
Last but not least, if Levent really needs bquote() [i.e. substitute()]
then, a final
as.expression(.)
may be needed :
identical(as.expression(quote(a == 1)),
expression( a == 1)) # --> TRUE
--
Martin Maechler, ETH Zurich
More information about the R-help
mailing list