title: Iteration: labelling multiple columns at once
body: <p>I need to label multiple variables at once. The basic approach I would like to use is</p>
  <pre><code>iris&lt;–iris
  attr(iris$Sepal.Length, &quot;label&quot;) &lt;- &quot;Sepal Length&quot;
  </code></pre>
  <p>I would like to iterate this process across all of my variables. Is there a compact way to do this?</p>
  <p>I have created a list of variables names and labels</p>
  <pre><code># First create my labels list.
  lablist&lt;-str_to_title(str_replace_all(names(iris), pattern = &quot;\\.&quot;, replacement = &quot; &quot;))
  # Second my variable names list
  namelist&lt;- names(iris)
  </code></pre>
  <p>But when I tried to iterate this my approach has failed: what am I doing wrong?</p>
  <pre><code># I attempt iteration
  map2(namelist,lablist,~attr(iris[,.x], &quot;label&quot;) &lt;- .y)
  </code></pre>
  <p>Ideally, I would want to use <code>map</code> for iteration, but I am open to alternative solutions if they are more compact and effective</p>
  <p>Thanks a lot for your help</p>