I have a dataset with some outliers, such as the following
x <- rnorm(1000,0,20)
x <- c(x, 500, -500)
If we plot this on a linear x a
Why suffer with ggplot2 solution? Your first plot was done with lattice histogram
function, and this is where you should stay. Just apply logarithmic transformation directly within histogram
function, use nint
argument to specify the number of histogram bins, and type
argument to choose between "count", or "density". I think that you got everything you need there, but maybe I'm missing some crucial detail of your question...
library(lattice)
histogram(log10(x), nint=50, type="count")