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.
尝试使用paste
函数进行expression
(有关详细信息,请参阅?plotmath
),例如:
plot(0, main = expression(paste("Emissions from ", PM[2.5], " in the United States from 1999 to 2008")))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.