reading ?plotmath you might notice that "_" isn't the propper
syntax for
subscripts. This will work:
ggtern(data=x11,aes(A,B,C,xend = c(0.7,.00,0.7),yend c(.30,.50,.0),zend
=c(.0,.50,0.3)))+
geom_point()+
theme_showarrows()+geom_segment(size=.5)+
geom_text_viewport(x=c(.45,.27,.37),y=c(.32,.29,.22),label=c("P[a]","P[b]","P[c]"),
parse=TRUE)
cheers.
Am 04.12.2017 um 15:37 schrieb Levent TERLEMEZ via
R-help:> Hi,
>
> My example code is this;
>
> x11<-data.frame(A=c(.6,.6,.6),B=c(.20,.20,.20),C=c(0.20,.20,.20))
> ggtern(data=x11,aes(A,B,C,xend = c(0.7,.00,0.7),yend = c(.30,.50,.0),zend
=c(.0,.50,0.3)))+
> geom_point()+
> theme_showarrows()+geom_segment(size=.5)+
>
geom_text_viewport(x=c(.45,.27,.37),y=c(.32,.29,.22),label=as.expression("P_a","P_b","P_c"))
>
> ggtern(data=x11,aes(A,B,C,xend = c(0.7,.00,0.7),yend = c(.30,.50,.0),zend
=c(.0,.50,0.3)))+
> geom_point()+
> theme_showarrows()+geom_segment(size=.5)+
>
geom_text_viewport(x=c(.45,.27,.37),y=c(.32,.29,.22),label=as.expression(quote(c("P_a","P_b","P_c"))))
>
> In geom_text_viewport (I also tried geom_label and geom_text versions)
tried all possible solutions, but i couldn't achieved. R command outputs are
like this:
>
> Error in stats::complete.cases(df[, vars, drop = FALSE]) :
> invalid 'type' (expression) of argument
>
>
> Maybe i am writing the code wrong, i couldn't figure out.
>
> Thanks for your kind answers.
>
>
>
> ________________________________________
> Kimden: Martin Maechler [maechler at stat.math.ethz.ch]
> G?nderildi: 04 Aral?k 2017 Pazartesi 16:16
> Kime: peter dalgaard
> Bilgi: Levent TERLEMEZ; R-help at r-project.org
> Konu: Re: [R] ggtern and bquote...
>
>>>>>> 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
>
>
> ________________________________
>
> Bu elektronik posta ve onunla iletilen b?t?n dosyalar sadece yukar?da
isimleri belirtilen ki?iler aras?nda ?zel haberle?me amac?n? ta??makta olup
g?nderici taraf?ndan al?nmas? ama?lanan yetkili ger?ek ya da t?zel ki?inin
kullan?m?na aittir. E?er bu elektronik posta size yanl??l?kla ula?m??sa,
elektronik postan?n i?eri?ini a??klaman?z, kopyalaman?z, y?nlendirmeniz ve
kullanman?z kesinlikle yasakt?r. Bu durumda, l?tfen mesaj? geri g?nderiniz ve
sisteminizden siliniz. Anadolu ?niversitesi bu mesaj?n i?erdi?i bilgilerin
do?rulu?u veya eksiksiz oldu?u konusunda herhangi bir garanti vermemektedir. Bu
nedenle bu bilgilerin ne ?ekilde olursa olsun i?eri?inden, iletilmesinden,
al?nmas?ndan ve saklanmas?ndan sorumlu de?ildir. Bu mesajdaki g?r??ler yaln?zca
g?nderen ki?iye aittir ve Anadolu ?niversitesinin g?r??lerini yans?tmayabilir.
>
> This electronic mail and any files transmitted with it are intended for the
private use of the people named above. If you are not the intended recipient and
received this message in error, forwarding, copying or use of any of the
information is strictly prohibited. Any dissemination or use of this information
by a person other than the intended recipient is unauthorized and may be
illegal. In this case, please immediately notify the sender and delete it from
your system. Anadolu University does not guarantee the accuracy or completeness
of any information included in this message. Therefore, by any means Anadolu
University is not responsible for the content of the message, and the
transmission, reception, storage, and use of the information. The opinions
expressed in this message only belong to the sender of it and may not reflect
the opinions of Anadolu University.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Eik Vettorazzi
Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf
Martinistrasse 52
building W 34
20246 Hamburg
Phone: +49 (0) 40 7410 - 58243
Fax: +49 (0) 40 7410 - 57790
Web: www.uke.de/imbe
--
_____________________________________________________________________
Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts;
Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard G?ke (Vorsitzender), Prof. Dr. Dr. Uwe
Koch-Gromus, Joachim Pr?l?, Martina Saurin (komm.)
_____________________________________________________________________
SAVE PAPER - THINK BEFORE PRINTING