title: How to compute weighted mean in R?
body: <p>How do I compute the weighted mean in <code>R</code>? </p>
  
  <p>For example, I have 4 elements of which 1 element is of size (or: length, width, etc.) 10 and 3 elements are of size 2. </p>
  
  <pre><code>&gt; z = data.frame(count=c(1,3), size=c(10,2))
  &gt; z
    count size
  1     1   10
  2     3    2
  </code></pre>
  
  <p>The weighted average is <code>(10 * 1 + 2 * 3) / 4 = 4</code>.</p>