In R, I'm wanting to create a graph with x axis label expression(varname), where varname is a character object. For example:
varname <- "beta[1]"
hist(rnorm(20),xlab=expression(varname))
But that gives me a graph with xlab="varname" rather than xlab=expression(beta[1]). How to I convince expression() to evaluate the variable?
you can do by
hist(rnorm(20),xlab=parse(text=varname))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With