R中的轴标签:p(Y = y | theta =某物) [英] Axis Labels in R: p(Y=y | theta = something)
问题描述
我已经搜索了所有内容,找不到像这样的具有条件符号的代码
I've searched all over and can't find the code for having a conditional sign as in
p(a | b)
我正在使用的代码(通用R代码,不是ggplot)是
The code (generic R code, not ggplot) I'm using is
ylab = bquote(Pr( Y == y | theta == .(mytheta) , n == .(n)))
这给我一个标签就是
Pr(|(Y = y,theta = 0.2),n = 10)
Pr(|(Y=y,theta=0.2), n=10)
theta是希腊文的正确符号,mytheta是0.2,n是10. 因此,所有不起作用的是条件标志.在我看来,R正在接受|或...
Where the theta is a proper Greek symbol, mytheta is 0.2, and n is 10. So all that's not working is the conditional sign. It looks to me like R is taking the | for an or...
我还没有尝试过ggplot,但是想首先让它在普通R中工作.
I haven't tried ggplot yet, but would like to get this working in plain R first.
感谢您的帮助.
推荐答案
我认为看到'pipe'(vs.'OR')被解析为波兰语表示法非常有趣.可以使用?plotmath
和?points
I thought it was pretty interesting to see that 'pipe' (vs. 'OR') get parsed into Polish notation. The conditional-bar can be accessed with the Symbol font using the methods described in ?plotmath
and ?points
plot(1,1, main=bquote(Pr( Y == y ~ symbol("\275") ~ theta == .(mytheta) , n == .(n))))
(我确实尝试使用%|%
作为缺少的条件符号来制作SPECIAL用户定义的函数,但失败了.)
(I did try making a SPECIAL user-defined function using %|%
as the missing conditional symbol, but failed.)
在您的评论问题中要求提供插图(实际上是两种等效使用方式substitute
的版本:
To your comment-question asking for an illustration (actually two versions of how to use substitute
in an equivalent manner:
mytheta = 0.2
plot(rnorm(100), rnorm(100), ylab= substitute(P(Y~"|"~ mytheta ), list(mytheta=mytheta)) )
plot(rnorm(100), rnorm(100), ylab= substitute(P(Y~"|"~ theta == mytheta ),
list(mytheta=mytheta)) )
# Second version prints greek-theta == value
这篇关于R中的轴标签:p(Y = y | theta =某物)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!