下标作为绘图标签中的变量

Subscripts as variable in plot label

我有 n 个带有下标标签的图。定义标签:

lab<-c("NO[2]","NO","CO[2]","CO")
lab2<-noquote(lab)
plot(1,1,xlab=bquote(.(lab[1])))
plot(1,1,xlab=bquote(.(lab2[1])))

我想要这个,但带有 .variable

plot(1,1,xlab=bquote(NO[2]))

有什么想法吗?

您必须 parse 字符串。

plot(1, 1, xlab = bquote(.(parse(text = lab[1]))))