r中的情节标题下标

时间:2014-08-27 15:35:39

标签: r plot subscript

我想添加标题,“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"))

由于方括号,我收到错误说明意外符号。

1 个答案:

答案 0 :(得分:10)

尝试paste的{​​{1}}功能(详见expression),例如:

?plotmath