Reputation: 2092
What is the best way to achieve the same result as: Kernel estimation of log-pdf
using ggplot2 instead of base graphics? I would like to do it with something similar to stat_density
as otherwise things get quickly complicated when combined with faceting etc.
Upvotes: 2
Views: 328
Reputation: 263342
Couldn't you just assign dlog_y= log(density(x)$y)
and call gglplot with that as your y-variable?
x = rnorm(100); dlog_y= log()
dev.new(width=4, height=4)
qplot(x = density(x)$x, y=dlog_y)
Upvotes: 0
Reputation: 22588
library(ggplot2)
x = rnorm(100)
dev.new(width=4, height=4)
qplot(x, stat='density', geom='line') + scale_y_log10()
Upvotes: 3