在R中的条件ifelse上添加上标

Adding upper subscript on conditional ifelse in R

我正在努力格式化 Name 列,以便在 Value 列大于 10 时添加上标。有什么建议吗?这是一个示例数据集。

 tibble(Name = LETTERS[1:10], 
        Value = sample(5:15,10))

结果应该是这样的: A^1 当值大于 10

set.seed(123)
d <- tibble(Name = LETTERS[1:10], 
       Value = sample(5:15,10)) %>%
  mutate(Name = if_else(Value>10, paste0(Name, "^1"), Name))


library(ggplot2)
ggplot(d, aes(Name, Value)) + geom_bar(stat = "identity") +
 scale_x_discrete("Axis label", labels = parse(text = d$Name)) +
  theme(axis.text.x = element_text(vjust=0))