On Aug 22, 2012, at 2:46 PM, Noia Raindrops wrote:

Hello,

Use 'parse' for converting from character to expression:

x <- c(100, 50, 10, 1, 0.1, 0.05, 0.001)
plot(log(x), yaxt = "n")

parse(text = sprintf("e^%d", axTicks(2)))
## expression(e^-6, e^-4, e^-2, e^0, e^2, e^4)

axis(2, at = axTicks(2), labels = parse(text = sprintf("e^%d", axTicks(2))), las = 1)

Here's a "parse-free" approach:

axis(2, at = axTicks(2), labels =
as.expression( sapply( axTicks(2), function(x) bquote(e^.(x)))),
        las = 1)

I have not found a case that makes one approach superior, although there seems to be an avoid-parse sentiment abroad in the R-cognoscenti.
--

David Winsemius, MD
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to