title: How to calculate Z-score by group
body: <p>I want to calculate Z-scores using means and standard deviations generated from each group. For example I have following table.  It has 3 groups of data, I can generate mean and standard deviation for each group. Then I use group 1 mean and SD to calculate the Zscores for group one data points, and etc...</p>
  
  <pre>
  > dat
     group level    y
  1      1     A 10.8
  2      1     B 12.0
  3      1     C  9.6
  4      1     A 12.0
  5      1     B  7.8
  6      1     C 10.8
  7      2     A  8.7
  8      2     B  9.2
  9      2     C  8.2
  10     2     A 10.0
  11     2     B 12.2
  12     2     C  8.2
  13     3     A 10.9
  14     3     B  8.3
  15     3     C 10.1
  16     3     A  9.9
  17     3     B 10.9
  18     3     C 10.3
  </pre>
  
  <p>I have learned from this blog on how to get summary data by group, but not sure how to go from there.</p>
  
  <p>Thanks.</p>