how can I simultaneously plot as two histograms the density of values in these two vectors:
interactors1 = c(-6.4, -3.7, -7.7, -4.6, -2.0, -5.5, -3.3, -5.8, -5.0, -4.5,
3.2, -0.1, -3.0, -9.2, -3.1, -8.5, -5.4, -9.1, -7.7, 2.2,
1.7, 3.4, -8.6, -0.5, -8.1)
and
noninteractors1 = c(-1, 0.1, 2.7, 0.4, 4.3)
Before you ask, yes I did check out this post
I want to use ggplot and not hist, because the plots look much better. When I melt the data into a data frame and plot counts everything is fine - I get this
interactors=data.frame(interactors1,noninteractors1)
ggplot(melt(interactors), aes(value, fill = variable))
+ geom_histogram(position = "dodge")
However, I don't need counts, I need densities.
When I do
ggplot(melt(interactors), aes(value, fill = variable))
+ geom_histogram(aes(y=..density..),position = "dodge")
I get a corny result . That can't be right because the sum of the densities*bins exceeds 1. What am I doing wrong? Any help would be appreciated.
P.S. I tried posting the plots, but it's not letting me...