I have some log-normal data. I would like to calculate means and confidence intervals on the log-scale and transform that for plotting on an the original scale. How can I do this in ggplot2?
Here's an example where I generate the log-normal dataset D
with data for two groups, A
with and B
, and plot the log-transformed data with confidence intervals:
D = data.frame(y=exp(c(rnorm(10, 1), rnorm(10, 3))), x=rep(c('A', 'B'), each=10))
ggplot(D, aes(x=x, y=log(y))) + stat_summary(fun.data='mean_cl_boot')
In the solution I'm seeking the means would be exp(1)
and exp(3)
rather than 1
and 3
and confidence intervals which extends longer upwards than downwards.