Axis Labels in R: p(Y=y | theta = something)

醉酒当歌 提交于 2019-12-01 20:43:47

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))))

(I did try making a SPECIAL user-defined function using %|% as the missing conditional symbol, but failed.)

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

I always just use expression. I haven't used bquote before.

edited

Sorry, I did a bunch of these and obviously exported the wrong one. Use paste not paste0.

plot(rnorm(100), rnorm(100), ylab= expression(paste("P(Y| ", theta," )")))

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!