title: R define levels without observations
body: <p>Is it possible to define factor levels for values that are not present in a vector?</p>
  
  <p>I'm trying to convert an integer vector (x) which doens't contain all possible values from my survey to a factor with matching labels. I want the value 3 to be labelled "Agree", but since it's the first value r comes across, it gets assigned the first level in my list of possible levels.</p>
  
  <pre><code>&gt; x &lt;- c(3L,3L,3L,3L,3L)
  &gt; x &lt;- as.factor(x)
  &gt; levels(x) &lt;- c("Strongly disagree","Disagree", "Agree", "Strongly agree")
  &gt; summary(x)
  </code></pre>
  
  <p>Results in: Strongly disagree: 5, while i would hope it would result in: Agree: 5 </p>
  
  <p>Can this be done?</p>