I would like to use ggplot2 to illustrate the difference between two identical density distributions. Here is an example toy for the data type that I have:
library(ggplot2)
n_sp <- 100000
n_dup <- 50000
D <- data.frame(
event=c(rep("sp", n_sp), rep("dup", n_dup) ),
q=c(rnorm(n_sp, mean=2.0), rnorm(n_dup, mean=2.1))
)
ggplot( D, aes( x=q, y=..density.., col=event ) ) +
geom_freqpoly()
Instead of the individual components of the density for each category ( dupand sp) as described above, I could build a separate line, which shows the difference between these distributions?
, dup sp, ( sp) 0 ( dup). , dup sp.
- ?