This question is related to a previous post.
Say I have this set of data test
:
a b c
1 a x NA
2 b x 5.1e-03
3 c x 2.0e-01
4 d x 6.7e-05
5 e x NA
6 f y 6.2e-05
7 g y 1.0e-02
8 h y 2.5e-03
9 i y 9.8e-02
10 j y 8.7e-04
> dput(test)
structure(list(a = structure(1:10, .Label = c("a", "b", "c",
"d", "e", "f", "g", "h", "i", "j"), class = "factor"), b = structure(c(1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("x", "y"), class = "factor"),
c = c(NA, 0.0051, 0.2, 6.7e-05, NA, 6.2e-05, 0.01, 0.0025,
0.098, 0.00087)), .Names = c("a", "b", "c"), row.names = c(NA,
-10L), class = "data.frame")
Plotting it regularly with ggplot will give this graph:
> ggplot(test, aes(fill=a,y=c,x=b)) +
geom_bar(position="dodge",stat="identity")
How do I set the y-axis as log scale (e.g., 0, 10-6, 10-5, 10-4 ... 100) so that the height of the bars won't be too far apart without directly log-transforming the data? Also, how do I accomplish this in such a way that it still shows the NA
values as zeroes in the graph?
I also tried the scale_y_log10()
function but the bars go from top to bottom. I would like them not to be that way.
Thank you!