title: faceting weighted histograms with ggplot2
body: <p>I'm trying to facet some weighted histograms. Here's my code:</p>
  
  <pre><code>data &lt;- structure(list(Weight = c(0.0111111, 0.0148148, 0.0222222, 0.00740741, 0.0222222, 0.285714, 0.133333, 0.133333, 0.0111111, 0.133333,  0.0148148, 0.133333, 0.0148148, 0.00740741, 0.00740741, 0.0111111,  0.00740741, 0.00740741, 0.00740741, 0.0222222, 0.00740741, 0.0148148, 0.00740741, 0.00740741, 0.00740741, 0.00740741, 0.00740741, 0.00740741, 0.00740741, 0.0148148, 0.00740741, 0.00740741, 0.0111111, 0.00740741, 0.133333, 0.00740741, 0.0222222, 0.0111111, 0.0111111, 0.133333), Times = c(7.49972, 3.03889, 3.09306, 1.59472, 2.55778, 0.263611, 2.88, 5.03944, 5.19833, 6.95722, 6.98889, 6.99778, 6.87361, 6.91361, 6.95056, 0.1, 6.34778, 5.78722, 6.95139, 0.145278, 0.0727778, 6.9275, 4.17222, 6.86694, 5.65028, 7.40306, 7.40306, 6.05111, 8.14944, 7.06806, 5.165, 7.62111, 0.174167, 7.40333, 0.189444, 6.95556, 6.96417, 0.213889, 6.96222, 0.3075), Distance = c(468.302, 261.584, 260.88, 124.67, 187.5, 10.6738, 184.596, 281.336, 286.554, 251.474, 252.63, 253.131, 250.407, 248.836, 251.438, 2.22492, 233.747, 237.356, 250.211, 3.77001, 1.48003, 251.094, 231.467, 250.386, 217.358, 368.035, 368.035, 356.509, 552.115, 255.06, 284.697, 469.364, 4.06013, 370.554, 5.21968, 251.989, 252.485, 5.40303, 249.193, 7.58435)), .Names = c("Weight", "Times", "Distance"), row.names = c(NA, 40L), class = "data.frame")
  
  mdata = melt(data)
  
  ggplot(mdata, aes(x=value)) +
  geom_histogram(weights = data$Weight) +
  facet_wrap(~variable, scales = "free")
  </code></pre>
  
  <p>Which produces:</p>
  
  <p><a href="https://i.stack.imgur.com/i8g9G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i8g9G.png" alt="enter image description here"></a></p>
  
  <p>My problem is that I don't want to plot "Weight" but use this column to actually weight the two other histograms ("Time" and "Distance"). What's the proper way to do this?</p>