R 使用glue::glue编写plotmath表达式,如斜体字体或希腊字母

R 使用glue::glue编写plotmath表达式,如斜体字体或希腊字母,r,tidyverse,plotmath,R,Tidyverse,Plotmath,有没有办法使用glue包来编写plotmath表达式?请参见下面的示例,其中我想使用glue::glue为绘图准备注释 或者,实际上,任何其他显示包含结果的标签的紧凑方式都会对我有所帮助 #需要库 图书馆(扫帚) 图书馆(统计) 图书馆(数据集) 图书馆(cowplot) 图书馆(GG2) #从线性回归模型中获得结果 res术语估计标准误差统计p值 #>1(截距)5.006 0.07280222 68.761639 1.134286e-113 #>2种颜色0.930 0.10295789.032

有没有办法使用
glue
包来编写plotmath表达式?请参见下面的示例,其中我想使用
glue::glue
为绘图准备注释

或者,实际上,任何其他显示包含结果的标签的紧凑方式都会对我有所帮助

#需要库
图书馆(扫帚)
图书馆(统计)
图书馆(数据集)
图书馆(cowplot)
图书馆(GG2)
#从线性回归模型中获得结果
res术语估计标准误差统计p值
#>1(截距)5.006 0.07280222 68.761639 1.134286e-113
#>2种颜色0.930 0.10295789.032819 8.770194e-16
#>3种弗吉尼亚1.582 0.10295789 15.365506 2.214821e-32
#准备带有“花色”物种结果的副标题
glue::glue(“对{res$term[2]}的估计是{expression(italic(beta))}={res$statistic[2]}”)#italic或beta在这里不起作用
#>SpeciesVersionColor的估计值为斜体(β)=9.03281939401064
#通常一个人会做这样的事情
cowplot::ggdraw(cowplot::add_sub(
plot=ggplot(data.frame())+geom_point()+xlim(0,10)+ylim(0,100),#创建空绘图
标签=替换(表达式=
粘贴(
“估计数”,
效果,,
“是”,
斜体(beta),
" = ",
估计
sep=“”
)
,env=base::list(effect=res$term[[2]],estimate=res$statistic[[2]]))
)
)


由(v0.2.0)于2018年2月25日创建。

而不是使用
替换
,一个紧凑的选项是
bquote

lbl <- bquote("The estimate for"~.(res$term[2])~is ~italic(beta) == .(res$statistic[2]))

cowplot::ggdraw(cowplot::add_sub(
 plot = ggplot(data.frame()) + 
                 geom_point() +
                 xlim(0, 10) +
                  ylim(0, 100), 
        label =  lbl))

lbl谢谢!这就是我想要的:一种简洁的方式来为标签写结果。直接转到
glue::glue
,但您的选择对我也适用。