我想添加标题“1999年至2008年美国PM2.5的排放量”,它使用r中的基本绘图函数。因此,我希望2.5是PM的下标如果PM2.5恰好在字符串的末尾,我这样做没有任何问题:
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] )但是如果它在字符串的中间,我就不能做同样的事情。如果我把它分成两部分,如下所示:
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"))我得到一个错误,说意外符号,因为方括号。
发布于 2014-08-27 23:42:52
尝试expression的paste函数(详情请参阅?plotmath ),例如:
plot(0, main = expression(paste("Emissions from ", PM[2.5], " in the United States from 1999 to 2008")))https://stackoverflow.com/questions/25531362
复制相似问题