I have a dataframe where one of the variables "Molecule" is categorical variable whose strings contain multiple subscripts. When I used ggplot2 to plot the Molecule against another variable, the ggplot graph did not print the subscripts as expected.
Code:
`hpc_combine %>%
slice(13:23) %>%
select(5,4) %>%
rename("Molecule" = 1) %>%
ggplot(aes(Molecule, Avg_Rel_abund)) +
geom_col(position = "dodge") +
theme(axis.text.x = element_text(face = "bold")) +
ylim(0, 5) +
coord_flip()``
Dataframe and plot are attached....
I have tried many approaches solutions, including codes using regular expressions, or the str2expression function, and ggtext, but none of these codes have worked. My hope is that I do not have to manually modify these data point names, as I have many of them. It seems this issue is different than related issues regarding subscripts in x-axis labels in ggplot2 because I am dealing with many strings in dataframe each with multiple subscripts that can't be addressed manually like some of the past solutions to similar problems. Any assistance is welcome!