title: Dividing a particular numeric column by maximum observation corresponding to another factor column
body: <p>I am working on a data set baseball in R in a package plyr.</p>
  
  <pre><code>require(plyr)
  head(baseball[,c(1,2,6:12)], n=7)
  
             id year  g  ab  r  h X2b X3b hr
  4   ansonca01 1871 25 120 29 39  11   3  0
  44  forceda01 1871 32 162 45 45   9   4  0
  68  mathebo01 1871 19  89 15 24   3   1  0
  99  startjo01 1871 33 161 35 58   5   1  1
  102 suttoez01 1871 29 128 35 45   3   7  3
  106 whitede01 1871 29 146 40 47   6   5  1
  113  yorkto01 1871 29 145 36 37   5   7  2
  </code></pre>
  
  <p>I am interested in dividing the value of variables g through hr (variables 6 through 12) in baseball by the maximum of each of those columns for each year (1871-2007). </p>
  
  <p>For example, year 1871, maximum for variable g=33</p>
  
  <p>So all the values of g falling under year 1871 will be divided by 33.</p>
  
  <p>year 1872, maximum for variable g=55</p>
  
  <p>So all the values of g falling under year 1872 will be divided by 55.</p>
  
  <p>tapply(g,year,max)</p>
  
  <p>I tried tapply to get maximum of of variables with respect to variable year. But how to divide the value of variables g through hr (variables 6 through 12) in baseball by the maximum of each of those columns for each year (1871-2007), i am not getting. please help!</p>