Does anyone know how I can plot factor levels containing text with superscripts? In the example below I would like to have A^1
and B^3
in the x-axis as superscript text (without '^')
# Fake dataframe
size <- 20
df <- data.frame(grp = sample(c("A^1", "B^3", "C"), size = size, replace = TRUE),
value = rnorm(size, mean = 10, sd = 1)) %>%
mutate(grp = as.factor(grp)) %>%
group_by(grp) %>%
summarise(mean = mean(value, na.rm=TRUE)) %>%
ungroup()
# barplot
df %>%
ggplot(aes(x = grp, y = mean)) +
geom_col()