title: R: split data based on a factor, add a ranking column and extract
body: <p>I still haven't been able to know how we can access different elements of a split data. Here is my problem:
  I have a data set, that I want to split based on a column (State). I want to have a ranking column added to my data for each subset. This is part of a function I'm writing. 
  My data set has 2 columns, Hospital, State, Outcome. For each state, I want to add a 'Rank' column that ranks the data based on Outcome; the lowest Outcome will be ranked 1 and the highest outcome will be ranked the last. </p>
  
  <p>How can I use split, sapply/lapply to do this? Is there a better way, like using "arrange"? 
  My main problem is that when I use either of these methods, I do not know how to access each element of the split or arranged data. 
  Here's how my data set looks like: 
  Hospital State Outcome. The row lines are not important here. </p>
  
  <pre><code>                           Hospital State Outcome 
   1 SOUTHEAST ALABAMA MEDICAL CENTER    AL    14.3
   2    MARSHALL MEDICAL CENTER SOUTH    AL    18.5
   3   ELIZA COFFEE MEMORIAL HOSPITAL    TX    18.1
   7                ST VINCENT'S EAST    TX    17.7
   8   DEKALB REGIONAL MEDICAL CENTER    AL    18.0
   9    SHELBY BAPTIST MEDICAL CENTER    AL    15.9
  </code></pre>
  
  <p>The desired outcome would be</p>
  
  <pre><code>                           Hospital State Outcome Rank
   1 SOUTHEAST ALABAMA MEDICAL CENTER    AL    14.3    1
   2 SHELBY BAPTIST MEDICAL CENTER       AL    15.9    2
   3 DEKALB REGIONAL MEDICAL CENTER      AL    18.0    3               
   4 MARSHALL MEDICAL CENTER SOUTH       AL    18.5    4 
   5 ST VINCENT'S EAST                   TX    17.7    1 
   6 ELIZA COFFEE MEMORIAL HOSPITAL      TX    18.1    2 
  </code></pre>
  
  <p>Thanks in advance. </p>