title: How to extract the text description of variables under variable name in R?
body: <p>I read a SPSS dataset using R. If I view the dataset, there is text description under the variable names. They should be understood as labels of the variables. But I cannot extract them by using label function. Is there anyway to extract them and define them as the label of the variables?<a href="https://i.stack.imgur.com/Jn1QM.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <hr>
  
  <p>Turns out these texts are stored as the attributes of the dataset. I can extract them using attr function</p>
  
  <pre><code>var.labels &lt;- attr(data, "variable.labels")
  </code></pre>
  
  <p>Then by the smart answer from <a href="https://stackoverflow.com/questions/27347548/r-assign-variable-labels-of-data-frame-columns">R: Assign variable labels of data frame columns</a>, I can assign them as variable labels by </p>
  
  <pre><code>label(data) = as.list(var.labels[match(names(data), names(var.labels))])
  </code></pre>