我找不到一种在R中在标题或副标题中写下标的方法。 如何将v 1,2 写成带有下标的形式?
感谢您的帮助!
expression
是你的朋友:
plot(1,1, main=expression('title'^2)) #superscript
plot(1,1, main=expression('title'[2])) #subscript
如果您想在一段文本中使用多个下标,请使用星号(*)来分隔这些部分:
plot(1:10, xlab=expression('hi'[5]*'there'[6]^8*'you'[2]))
plot(1:10, xlab=expression('hi'[5]*'there'[6]^8*'you'['down here']*'and'^'up'*'there'))
- Stewart Macdonald[digits]
жҲ–[characters]
з”ҡиҮі[a5]
пјҢдҪҶдёҚиғҪж”ҫзҪ®[5a]
жҲ–[a a]
гҖӮжҲ‘жңҖиҝ‘еҸ‘зҺ°дәҶиҝҷдёӘз”Ёжі•пјҡexpression('x'['10sdt'])
гҖӮ - Cyrille查看?expression
plot(1:10,main=expression("This is a subscript "[2]))
title(xlab=expression("Nitrate Loading in kg ha"^-1*"yr"^-1))
当您编写上标或下标并需要在表达式后添加更多文本时,只需使用*分隔各个部分(如上所述)。
bquote
函数。例如,假设你有一个变量nIter <- 2
,那么plot(1, 1, main = bquote(title[.(nIter)]))
正是你需要的(摘自R-help mailing list)。 - fdetsch