gpt4 book ai didi

r - R : p(Y=y | theta = something) 中的轴标签

转载 作者:行者123 更新时间:2023-12-01 11:47:31 26 4
gpt4 key购买 nike

我找遍了,找不到像这样的条件符号的代码

p(a|b)

我使用的代码(通用 R 代码,不是 ggplot)是

ylab = bquote(Pr( Y == y |  theta == .(mytheta) , n == .(n)))

这给我的标签是

Pr(|(Y=y,theta=0.2), n=10)

theta 是一个希腊符号,mytheta 是 0.2,n 是 10。所以所有不起作用的是条件标志。在我看来 R 正在接受 |对于一个或...

我还没有尝试过 ggplot,但我想先在纯 R 中使用它。

感谢您的帮助。

最佳答案

我认为看到“pipe”(相对于“OR”)被解析为波兰语表示法非常有趣。可以使用 ?plotmath?points

中描述的方法使用 Symbol 字体访问条件栏
plot(1,1, main=bquote(Pr( Y == y ~ symbol("\275") ~ theta == .(mytheta) , n == .(n))))

(我曾尝试使用 %|% 作为缺少的条件符号来创建一个特殊的用户定义函数,但失败了。)

对于您的评论问题,要求提供插图(实际上是如何以等效方式使用 substitute 的两个版本:

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 - R : p(Y=y | theta = something) 中的轴标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35232798/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com