Marking center marks with greek symbols from vector

I'm struggling to build Greek characters as axis labels. Due to the cyclization of several graphs with different scales, I would like to use a vector that contains the symbol name, instead of using the symbol name inside expression(), which works fine:

x <- rnorm(10, 5,6)
y <- rnorm(10, 2,1)
xlab <- expression(paste(mu, "mol/mol"))
plot(x,y, xlab = xlab)

For some reason, I cannot replace "mu" with a vector containing the symbol name:

k <- "mu"
xlab <- expression(paste(get(k), "mol/mol"))
plot(x,y, xlab = xlab)

I found a similar question , but what worked for functions doesn't seem to work for Greek characters:

ylab <- substitute(paste(nn, "mol/mol"), list(nn=k))
xlab <- bquote(.(k) * "mol/mol")

plot(x,y, ylab = ylab, xlab = xlab)

How am I wrong? How to get the symbol of the Greek symbol along the axis through the vector?

+5
source share
1 answer

Try the following:

xlab = parse(text=paste(k, "*mol/mol"))
+5
source

All Articles