Gorjanc Gregor
2005-Jun-28 15:42 UTC
[R] Producing character "given" i.e. "| " with plotmath
Hello! Does someone know how to produce L(y|mu) with plotmath? Some code with unsuccessfull results: plot(dnorm(x = seq(from = -4, to = 4, by = 0.1)), type = "l") ## Not what I want legend(legend = c(expression(L(y:mu))), x = "topright") ## Strange, is this a bug? legend(legend = c(expression(L(y|mu))), x = "top") ## Group produces an error legend(legend = c(expression(group(L(y, "|", mu)))), x = "topleft") ## Paste keeps commas in expression legend(legend = c(expression(paste(L(y, "|", mu)))), x = "bottomleft") ## This one is OK, but braces are not as they should be legend(legend = c(expression(paste("L(y", "|", "mu)"))), x = "bottom") Thanks! Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana Biotechnical Faculty URI: http://www.bfro.uni-lj.si/MR/ggorjan Zootechnical Department mail: gregor.gorjanc <at> bfro.uni-lj.si Groblje 3 tel: +386 (0)1 72 17 861 SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europe ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
Gorjanc Gregor wrote:> Hello! > > Does someone know how to produce > > L(y|mu) > > with plotmath? > > Some code with unsuccessfull results: > > plot(dnorm(x = seq(from = -4, to = 4, by = 0.1)), type = "l") > ## Not what I want > legend(legend = c(expression(L(y:mu))), x = "topright") > > ## Strange, is this a bug? > legend(legend = c(expression(L(y|mu))), x = "top")No, "|" is a logical Operator that can be rewritten in its original function form as follows: "|"(FALSE, TRUE) Hence the result is expected.> ## Group produces an error > legend(legend = c(expression(group(L(y, "|", mu)))), x = "topleft")You have not specified any delimiter.> ## Paste keeps commas in expression > legend(legend = c(expression(paste(L(y, "|", mu)))), x = "bottomleft")correct> ## This one is OK, but braces are not as they should be > legend(legend = c(expression(paste("L(y", "|", "mu)"))), x = "bottom")What's wrong with the braces?` What you really want is: legend(legend = c(expression(L(group("", y, "|") * mu))), x = "center") Uwe Ligges> Thanks! > > Lep pozdrav / With regards, > Gregor Gorjanc > > ---------------------------------------------------------------------- > University of Ljubljana > Biotechnical Faculty URI: http://www.bfro.uni-lj.si/MR/ggorjan > Zootechnical Department mail: gregor.gorjanc <at> bfro.uni-lj.si > Groblje 3 tel: +386 (0)1 72 17 861 > SI-1230 Domzale fax: +386 (0)1 72 17 888 > Slovenia, Europe > ---------------------------------------------------------------------- > "One must learn by doing the thing; for though you think you know it, > you have no certainty until you try." Sophocles ~ 450 B.C. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Gorjanc Gregor
2005-Jun-29 11:29 UTC
[R] Producing character "given" i.e. "| " with plotmath
>> Hello! >> >> Does someone know how to produce >> >> L(y|mu) >> >> with plotmath? >> >> Some code with unsuccessfull results: >> >> plot(dnorm(x = seq(from = -4, to = 4, by = 0.1)), type = "l") >> ## Not what I want >> legend(legend = c(expression(L(y:mu))), x = "topright") >> >> ## Strange, is this a bug? >> legend(legend = c(expression(L(y|mu))), x = "top")> No, "|" is a logical Operator that can be rewritten in its original > function form as follows: > > "|"(FALSE, TRUE) > > Hence the result is expected.Yes, that makes sense. Thanks!>> ## Group produces an error >> legend(legend = c(expression(group(L(y, "|", mu)))), x = "topleft")> You have not specified any delimiter.Ok, I got this point wrong from ?plotmath .>> ## Paste keeps commas in expression >> legend(legend = c(expression(paste(L(y, "|", mu)))), x = "bottomleft")>correct>> ## This one is OK, but braces are not as they should be >> legend(legend = c(expression(paste("L(y", "|", "mu)"))), x = "bottom")> What's wrong with the braces?`They are not the same as in previous cases. They are not "bold".> What you really want is: > legend(legend = c(expression(L(group("", y, "|") * mu))), > x = "center")Yes, that is what I want. Thanks! I got additionally response from Roger D. Peng, which stated:> How about > legend(legend = expression("L(y | " * mu * ")"), x = "topleft")That's also OK, but note above comment about "bold" braces. Regards, Gregor