ggplot2 facet labeler 双下标

ggplot2 facet labeller double subscript

我正在绘制带有双下标的变量,我希望能够防止下标在分面条文本中混在一起。每个标签应显示类似 $\beta_{1, 12}$ 而不是 $\beta_112$。修复以下MWE应该就足够了。

d = data.frame(
  x = rnorm(6),
  y = rnorm(6), 
  z = rep(paste0("beta[", 1:3, "][", 12, "]"), each = 2))
library(ggplot2)
pl = ggplot(d) + 
  geom_point(aes(x, y)) + 
  facet_wrap(~z, labeller = label_parsed)

这个怎么样?

library(ggplot2)

d = data.frame(
  x = rnorm(6),
  y = rnorm(6), 
  z = rep(paste0("beta[", 1:3, "~~", 12, "]"), each = 2))
pl = ggplot(d) + 
  geom_point(aes(x, y)) + 
  facet_wrap(~z, labeller = label_parsed)
pl