I would like to add the title, " Emissions from PM2.5 in the United States from 1999 to 2008" which uses the base plotting function in r. In that, I would like 2.5 to be a subscript to PM. I don't have any problem doing that if PM2.5 happens to be at the end of the string:
barplot(height = total.emissions$Emissions, names.arg=total.emissions$year,
xlab="Year", ylab= " Amount of emitted in tonsPM"2.5 ,
main = "Emissions from in the United States from 1999 to 2008PM"[2.5] )
But I can't do the same if it is in the middle of the string. If I split it into 2 parts as follows:
barplot(height = total.emissions$Emissions, names.arg=total.emissions$year,
xlab="Year", ylab= " Amount of PM_[2.5] emitted in tons",
main = expression("Emissions from PM"[2.5] "in the United States from 1999 to 2008"))
I get an error saying unexpected symbol because of the square brackets.
Try the paste
function for expression
(see ?plotmath
for details), e.g.:
plot(0, main = expression(paste("Emissions from ", PM[2.5], " in the United States from 1999 to 2008")))