title: state names to abbreviations using R
body: <p>I have an Excel file with name MASTER and I have a column name states.</p>
  
  <p>The state names are mix of abbreviations and full names. I want all full names to be converted to abbreviation. I've tried this code, but I don't know what I am doing wrong:</p>
  
  <pre><code>MASTER&lt;- read.csv("c:\\users\\Desktop\\test merge\\MASTER.csv", header=T, sep=",")
  &gt; MASTER = c("CALIFORNIA","ARIZONA","ARKANSAS","colorado","CONNECTICUT","DISTRICT OF COLUMBIA","FLORIDA","Georgia","hawaii","Illinois","Indiana","Iowa","kansas","Kentucky","LOUISIANA","Maine","Marryland","Massachusetts","Michigan","Minnesota","Missouri","MONTANA","NEBRASKA","Nevada","New Hampshire","New Jersey","NEW MEXICO","New York","North Carolina","OHIO","OKLAHOMA","Oregon","palmer","PANAMA","Pennsylvania","SOUTH CAROLINA","SOUTH DAKOTA","Tejas","Tennessee","Texas","TX.","UTAH","Virgin Islands","VIRGINIA","Washington","West Virginia","WISCONSIN","Wyoming")
  &gt; MASTER$state &lt;- state.abb[match(MASTER$state,state.name)]
  Error in `$&lt;-.data.frame`(`*tmp*`, state, value = character(0)) : 
    replacement has 0 rows, data has 635768
  </code></pre>