title: Scale all values depending on group
body: <p>I have a dataframe similar to this one</p>
  
  <pre><code>ID &lt;- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3)
  p1 &lt;- c(21000, 23400, 26800, 2345, 23464, 34563, 456433, 56543, 34543,3524, 353, 3432, 4542, 6343, 4534 )
  p2 &lt;- c(234235, 2342342, 32, 23432, 23423, 2342342, 34, 2343, 23434, 23434, 34, 234, 2343, 34, 5)
  my.df &lt;- data.frame(ID, p1, p2)
  </code></pre>
  
  <p>Now I would like to scale the values in p1 and p2 <strong>depending on their ID</strong>. So not the whole column would be scaled like when using the tapply() function, but rather scaling is done once for all values for ID 1, then for all values for ID 2 etc. Same for scaling of p2. The new dataframe should consist of the scaled values.</p>
  
  <p>I already tried </p>
  
  <pre><code>df_scaled &lt;- ddply(my.df, my.df$ID, scale(my.df$p1))
  </code></pre>
  
  <p>but get the error message </p>
  
  <pre><code>.fun is not a function.
  </code></pre>
  
  <p>Thanks for your help!</p>