title: Compute population sd for grouped variables
body: <p>This is my tibble:</p>
  <pre><code>df &lt;- tibble(x = c(&quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;b&quot;, &quot;b&quot;, &quot;b&quot;), y = c(1,2,3,4,6,8))
  df
  # A tibble: 6 x 2
    x         y
    &lt;chr&gt; &lt;dbl&gt;
  1 a         1
  2 a         2
  3 a         3
  4 b         4
  5 b         6
  6 b         8
  </code></pre>
  <p>I want to compute the poulation sd for the grouped variables of x.</p>
  <p>I tried it with this function:</p>
  <pre><code>sqrt((n-1)/n) * sd(x)
  </code></pre>
  <p>and dplyr and it looked like this:</p>
  <pre><code>df %&gt;%
    group_by(x) %&gt;%
    summarise(sd = sqrt((length(df$y)-1)/length(df$y)) * sd(y)) %&gt;%
    ungroup()
  
  # A tibble: 2 x 2
    x        sd
  * &lt;chr&gt; &lt;dbl&gt;
  1 a     0.913
  2 b     1.83 
  </code></pre>
  <p>Ofcourse this is incorrect, since the length argument is not grouped and therefore takes n = 6 and not n = 3.
  I should get</p>
  <pre><code>a = 0.8164966
  b = 1.632993
  </code></pre>
  <p>Edit:</p>
  <p>The output should be a tibble with the variables i have grouped and the sd for every group.</p>