title: Getting the labels of the column names (hmisc)
body: <p>I have used the <code>Hmisc</code> library to attach labels to column names, which you could do as follows.</p>
  
  <p><a href="https://www.statmethods.net/input/variablelables.html" rel="nofollow noreferrer">example</a> </p>
  
  <pre><code>library(Hmisc)
  label(mydata$myvar) &lt;- "Variable label for variable myvar" 
  </code></pre>
  
  <p>Results:</p>
  
  <p><a href="https://i.stack.imgur.com/RU2Ia.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RU2Ia.jpg" alt="enter image description here"></a></p>
  
  <p>It would be possible to set the labels for an entire <code>df</code> using a df called <code>Lbl</code> with in one column the names and one column the labels;</p>
  
  <pre><code>  Varcode Variables
  1 P       Power
  2 H       Happiness
  </code></pre>
  
  <p>as follows:</p>
  
  <pre><code># set labels
  for (i in seq_len(nrow(Lbl))) {
    Hmisc::label(df2[[Lbl$Varcode[i]]]) &lt;- Lbl$Variables[i]
  }
  </code></pre>
  
  <p>My question however is, if I have a labeled dataframe, how would I get them out (ie. reverse the command)?</p>