An alternative solution to that of @Aaron is the bquote()
function. We need to supply a valid R expression, in this case LABEL ~ x^2
for example, where LABEL
is the string you want to assign from the vector labNames
. bquote
evaluates R code within the expression wrapped in .( )
and subsitutes the result into the expression.
Here is an example:
labNames <- c('xLab','yLab')
xlab <- bquote(.(labNames[1]) ~ x^2)
ylab <- bquote(.(labNames[2]) ~ y^2)
plot(c(1:10), xlab = xlab, ylab = ylab)
(Note the ~
just adds a bit of spacing, if you don't want the space, replace it with *
and the two parts of the expression will be juxtaposed.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…