【发布时间】:2012-04-26 17:42:15
【问题描述】:
我找不到如何在标题或 R 中的副标题中编写下标的方法。 如何用 1,2 作为下标写 v 1,2?
感谢您的帮助!
【问题讨论】:
我找不到如何在标题或 R 中的副标题中编写下标的方法。 如何用 1,2 作为下标写 v 1,2?
感谢您的帮助!
【问题讨论】:
expression是你的朋友:
plot(1,1, main=expression('title'^2)) #superscript
plot(1,1, main=expression('title'[2])) #subscript
【讨论】:
bquote。比如说nIter <- 2,那么plot(1, 1, main = bquote(title[.(nIter)])) 正是你所需要的(取自R-help mailing list)。
见?表达式
plot(1:10,main=expression("This is a subscript "[2]))
【讨论】:
如果您希望在一个文本中包含多个下标,请使用星号 (*) 分隔各个部分:
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'))
[digits] 或[characters] 甚至[a5] 放在下标中,但不能将[5a] 或[a a]。我最近发现了这个:expression('x'['10sdt'])
另一个例子,表达式适用于负上标,不需要在负数周围加上引号:
title(xlab=expression("Nitrate Loading in kg ha"^-1*"yr"^-1))
并且你只需要*来分隔上面提到的部分(当你写一个上标或下标并且需要在后面的表达式中添加更多文本时)。
【讨论】: