I need to plot some data and one of the plot has to have the sulphate formula (SO42-) in the labels.
I am using this code
a=c(1,2,3,4,5)
b=c(1,2,3,4,5)
dd=data.frame(a,b)
G<-ggplot(dd)+
geom_line(x=a, y=b, color="blue")+
labs(x="Depth (m)", y=expression("nss SO"[4]^{2-}"(ppb)"))
G
And, of course, it doesn't work: either the - is written as a dash between the 2 and the ppb or it simply does nothing after giving me a wall of text. Am I missing something?