I would like to get a mirrored histogram by group using ggplot as illustrated in the picture at the bottom.
library(ggplot2)
data2 <- data.frame(
type = c( rep("Top 1", n_segment),
rep("Top 2", n_segment),
rep("Bottom 1", n_segment),
rep("Bottom 2", n_segment)),
value = c( rnorm(n_segment, mean=5),
rnorm(n_segment, mean=12),
rnorm(n_segment, mean=-5),
rnorm(n_segment, mean=-12))
)
# Represent it
data2 %>%
ggplot( aes(x=value, fill=type)) +
geom_density( color="#e9ecef", alpha=0.6)
For now I am getting this:



