title: apply() and calculating proportion of first row for all dataframe rows
body: <p>I have a dataframe as shown below listing the number of injuries by vehicle type:</p>
  
  <pre><code>trqldnum &lt;- data.frame(motorveh=c(796,912,908,880,941,966,989,984),
                         motorcyc=c(257,295,326,313,403,389,474,496),
                         bicyc=c(109,127,125,137,172,146,173,178))
  trqldnum
  
  #  motorveh motorcyc bicyc
  #1      796      257   109
  #2      912      295   127
  #3      908      326   125
  #4      880      313   137
  #5      941      403   172
  #6      966      389   146
  #7      989      474   173
  #8      984      496   178
  </code></pre>
  
  <p>At the moment I am calculating a proportion of the first row for each vehicle type using:</p>
  
  <pre><code>trqldprop &lt;- t(apply(trqldnum,1,function(x) {
                   x/c(trqldnum[1,1],trqldnum[1,2],trqldnum[1,3])
                }))
  trqldprop
  
  #  motorveh motorcyc    bicyc
  #1 1.000000 1.000000 1.000000
  #2 1.145729 1.147860 1.165138
  #3 1.140704 1.268482 1.146789
  #4 1.105528 1.217899 1.256881
  #5 1.182161 1.568093 1.577982
  #6 1.213568 1.513619 1.339450
  #7 1.242462 1.844358 1.587156
  #8 1.236181 1.929961 1.633028
  </code></pre>
  
  <p>This seems a bit ugly and I would need to manually change the denominator of the function if the data changed shape. I end up with the output in a list of a lists if I try to just use the following within the apply() statement. </p>
  
  <pre><code>function(x) x/c(trqldnum[1,])
  </code></pre>
  
  <p>I'd prefer to end up with the dataframe result as above but am just getting in a muddle trying to figure it out.</p>