Let's say I have the following data :
c1 <- runif(100, 0,1)
c2 <- runif(100, 0,1)
weights <- runif(100, 1,50)
categorie <- rbinom(100,1,0.5)
df <- as.data.frame(cbind(c1,c2,weights,categorie))
I would like to represent in the same plot the two distributions of c1 given that categorie=0 or given that categorie=1, and I would like to weight each observation by the variable weights. Futhermore, in y axis, I would like to have weighted proportions and not weighted numbers.
I would like to do a graph like this :

How can I do that with ggplot2?
Thanks a lot!
From the comments, it appears you are looking for two groups according to
categorie. Then you want a histogram which shows the weighted percentage of each bin as it applies to each group. I would probably pre-calculate this and draw it withgeom_col: