为 plotreg 变量标签添加上标和下标

Add superscripts and subscripts to plotreg variable labels

我想知道如何调整 plotreg()gl() 函数(它是 texreg 包中的函数)以适应包含超脚本或子脚本的变量标签?

我尝试过 expression()paste() 但无济于事。我在下面提供了一个工作示例(来自 their documentation):

# install.packages("texreg")
library(texreg)

ctl <- c(4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14)
trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69)
group <- gl(2, 10, 20, labels = c("Ctl", "Trt")) # need to tweak this part
# for example, Ctl^2, Trt[2]
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
lm.D90 <- lm(weight ~ group - 1)
plotreg(lm.D9) # plot model output as a diagram

下面是如何使用 ggplot2 更改轴标签。

library(ggplot2)

g <- plotreg(lm.D90)

labs <- c(expression(Ctl^2),expression(Trt[2]))

g <- g + scale_x_discrete(labels = labs)