title: Save variable labels in R so that Stata can read them
body: <p>I have a dataset with over <code>170</code> variables that looks as follows:</p>
  
  <pre><code>df &lt;- data.frame(var1 = 1:3, var2 = 2:4, var3 = 2:4, var4 = 2:4, var5 = 2:4)
  </code></pre>
  
  <p>I have manually added variable values using <code>Hmisc</code>:</p>
  
  <pre><code>library(Hmisc)
  var.labels = c(var1 = "label 1",
                 var3 = "label 2",
                 var4="label 4" )
  label(df) = as.list(var.labels[match(names(df), names(var.labels))])              
  </code></pre>
  
  <p>Do note that not all variables have labels and that it is much easier for me to specify variable labels by name (<code>var*</code>), rather than position given my large number of colums. </p>
  
  <p>The problem is that when I save my dataset with <code>write.csv(df,"df.csv")</code>or with <code>write.dta(df,"df.dta")</code> my variable labels get lost. </p>
  
  <p>How can I save the data in a way that can be re-imported into R and Stata with the labels restored?</p>