title: How to switch rows in R?
body: <p>I have a array with following content:</p>
  
  <pre><code>&gt; head(MEAN)
  1901DJF     1901JJA     1901MAM     1901SON     1902DJF     1902JJA 
  -0.45451556 -0.72922229 -0.17669396 -1.12095590 -0.86523850 -0.04031273 
  </code></pre>
  
  <p>This should be a time series with seasonal mean values from 1901 to 2009. The problem is that the generated column heads are strictly alphabetically ordered. However, in terms of season this doesn't make to much sense, e.g. JJA (june, july, august) is leading MAM (march, april, may).</p>
  
  <p>How could I switch each MAM and JJA entry of the array?</p>
  
  <p>PS: MEAN is generated applying tapply on the data.frame pdsi</p>
  
  <pre><code>&gt; head(pdsi)
      date      scPDSI month seas seasyear
  1 1901-01-01 -0.10881074   Jan  DJF  1901DJF
  2 1901-02-01 -0.22287750   Feb  DJF  1901DJF
  3 1901-03-01 -0.12233192   Mär  MAM  1901MAM
  4 1901-04-01 -0.04440915   Apr  MAM  1901MAM
  5 1901-05-01 -0.36334082   Mai  MAM  1901MAM
  6 1901-06-01 -0.52079030   Jun  JJA  1901JJA
  &gt;
  &gt; MEAN &lt;- tapply(pdsi$scPDSI, ts.pdsi$seasyear, mean, na.rm = T)
  </code></pre>
  
  <p>May be there is also known a more elegant way to calculate seasonal means...</p>