title: Confusion between factor levels and factor labels
body: <p>There seems to be a difference between levels and labels of a factor in R.
  Up to now, I always thought that levels were the 'real' name of factor levels, and labels were the names used for output (such as tables and plots). Obviously, this is not the case, as the following example shows:</p>
  
  <pre><code>df &lt;- data.frame(v=c(1,2,3),f=c('a','b','c'))
  str(df)
  'data.frame':   3 obs. of  2 variables:
   $ v: num  1 2 3
   $ f: Factor w/ 3 levels "a","b","c": 1 2 3
  
  df$f &lt;- factor(df$f, levels=c('a','b','c'),
    labels=c('Treatment A: XYZ','Treatment B: YZX','Treatment C: ZYX'))
  levels(df$f)
  [1] "Treatment A: XYZ" "Treatment B: YZX" "Treatment C: ZYX"
  </code></pre>
  
  <p>I thought that the levels ('a','b','c') could somehow still be accessed when scripting, but this doesn't work:</p>
  
  <pre><code>&gt; df$f=='a'
  [1] FALSE FALSE FALSE
  </code></pre>
  
  <p>But this does:</p>
  
  <pre><code>&gt; df$f=='Treatment A: XYZ' 
  [1]  TRUE FALSE FALSE
  </code></pre>
  
  <p>So, my question consists of two parts:</p>
  
  <ul>
  <li><p>What's the difference between levels and labels?</p></li>
  <li><p>Is it possible to have different names for factor levels for scripting and output?</p></li>
  </ul>
  
  <p>Background: For longer scripts, scripting with short factor levels seems to be much easier. However, for reports and plots, this short factor levels may not be adequate and should be replaced with preciser names. </p>