title: Recode/relevel data.frame factors with different levels
body: <p>Each time when I have to recode some set of variables, I have SPSS recode function in mind. I must admit that it's quite straightforward. There's a similar <code>recode</code> function in <code>car</code> package, and it does the trick, but let's presuppose that I want to get things done with <code>factor</code>.</p>
  
  <p>I have <code>data.frame</code> with several variables with value range from 1 to 7. I want to "reverse" variable values, hence replacing 1s with 7s, 2s with 6s, 3s with 5s etc. I can utilize <code>factor</code> function:</p>
  
  <pre><code># create dummy factor
  set.seed(100)
  x &lt;- as.factor(round(runif(100,1,7)))
  y &lt;- factor(x, levels = rev(levels(x)))
  </code></pre>
  
  <p>And if I run:</p>
  
  <pre><code>&gt; levels(x)
  [1] "1" "2" "3" "4" "5" "6" "7"
  &gt; levels(y)
  [1] "7" "6" "5" "4" "3" "2" "1"
  </code></pre>
  
  <p>Problem starts when I want to recode factors that do not have equal levels. If some factor, z, has levels <code>c("1", "3", "4", "6", "7")</code>, is there any chance that I can "reverse" levels so 1=7, 2=6, 3=5 etc. by utilizing <code>factor</code> function?</p>
  
  <p>Other efficient recode functions should suffice!</p>