title: Use values from Stata to R data.frame but show labels instead of values
body: <p>I am quite new to <code>R</code> and more used to <code>Stata</code>.</p>
  
  <p>I managed to read a database from <code>Stata</code> to a <code>R</code> <code>data.frame</code> using <code>library(foreign)</code>. </p>
  
  <pre><code>data=read.dta("mydata.dta", 
       convert.dates = TRUE, 
       convert.factors = TRUE,
       missing.type = FALSE,
       convert.underscore = FALSE, 
       warn.missing.labels = TRUE)
  </code></pre>
  
  <p><strong>Values</strong> (in the sens of Stata language) are however not imported, only <strong>labels</strong> are imported. </p>
  
  <p>Let me explain it a little more. Assume I want to manipulate an education variable called "edu". In Stata language, I use <strong>numeric values</strong> instead of <strong>labels</strong> to manipulate my variable and the data editor shows the labels, so long as I have defined my labels. Assume for instance that my variable "edu" takes the values 10 to 40, the following code associates a label to each value:</p>
  
  <pre><code>label define lib_edu 
  10 "Less than high-school degree" 
  20 "12th grade or higher, no college degree" 
  30 "Undergraduate level (2 to 4 years of college)" 
  40 "Graduate level (5 years of college or more)", add;
  label values edu lib_edu;
  </code></pre>
  
  <p>Then, when I want to manipulate my variable, I need to use the values. For example if I want to drop from my dataset people whose label is less than high-school degree, I simply do:</p>
  
  <pre><code>drop if edu==10
  </code></pre>
  
  <p>But in my imported <code>R</code> <code>data.frame</code>, the labels are being imported as factors. To each factor is associated a level which does not necessarily correspond to my Stata values since it restarts from 1. Meanwhile, I cannot use levels to manipulate my variable. If I want to drop from my dataset people whose label is less than high-school degree, I have to write the entire label:</p>
  
  <pre><code>data &lt;- data[data$edu!="Less than high-school degree",]
  </code></pre>
  
  <p>which is not convenient at all, especially when the label is long and complex.</p>
  
  <p>Is it possible to do as in Stata, that is: manipulate numeric values while editing the data.frame with labels, given that my data are exported from Stata?</p>
  
  <p>Thanking you in advance.</p>