title: Removing S3 labels in a list
body: <p>I am working with a large dataset downloaded dataset with the end goal of joining many data frames.</p>
  <p>For the past week or so, I have been unable to join data frames due to incompatibility of the data types &quot;labelled&quot; vs. &quot;character.&quot; Ultimately I would like to map my function to the same variable in multiple data frames in a list.</p>
  <p>Structure of each df is as follows (edited to change variables/attr names because I cannot share the data). The variable of interest I'm working with here is &quot;CODE&quot;:</p>
  <pre><code>structure(list(VAR1 = structure(c(val, val, val, val, val, val), .Label = c(&quot;a&quot;, 
  &quot;b&quot;, &quot;c&quot;, &quot;d&quot;), class = &quot;factor&quot;), ID = c(1, 
  2, 3, 4, 5, 6), CODE = structure(c(&quot;c1&quot;, &quot;c1&quot;, 
  &quot;c1&quot;, &quot;c1&quot;, &quot;c1&quot;, &quot;c1&quot;), label = &quot;instance code&quot;, units = &quot;-4&quot;, class = c(&quot;labelled&quot;, 
  &quot;character&quot;)), ...
  </code></pre>
  <p>I'm still relatively new to R/RStudio, so I thought for a while my issue was with mapping throughout the list, but when I pick one element to remove labels, it still doesn't work. It is almost as if R doesn't know that the label is there, despite the fact that when I use get_label, the label shows up (function below).</p>
  <pre><code>get_label(my.list[[&quot;my.df&quot;]][[&quot;my.variable&quot;]]
  </code></pre>
  <p>I have tried the following methods (I am showing it as if I am working with a single variable instead of the whole list, which is how I have been experimenting for the last couple of days):</p>
  <ol>
  <li>The class function. Interestingly, when I call this back, it says the class is character; however, when I look at the dataframe, the class still says &quot;character [# of elements] (S3: labelled, character)&quot;</li>
  </ol>
  <pre><code>class(my.list[[&quot;my.df&quot;]][[&quot;my.variable&quot;]] &lt;- &quot;character&quot;
  </code></pre>
  <ol start="2">
  <li>remove_label function</li>
  </ol>
  <pre><code>remove_label(my.list[[&quot;my.df&quot;]][[&quot;my.variable&quot;]]
  </code></pre>
  <ol start="3">
  <li>unclass function. This one worked for one variable at a time, but did not map over the whole list, so I am including my mapping code in case that is the issue in this case.</li>
  </ol>
  <pre><code>## for one variable
  unclass(my.list[[&quot;my.df&quot;]][[&quot;my.variable&quot;]])
  
  ## for entire list
  my.list %&gt;%
  map_at(&quot;my.variable&quot;, ~ unclass)
  
  ## I also tried map in case it was a map_at issue--still didn't work.
  </code></pre>
  <ol start="4">
  <li>zap_label</li>
  </ol>
  <pre><code>zap_label(my.list[[&quot;my.df&quot;]][[&quot;my.variable&quot;]])
  </code></pre>
  <ol start="5">
  <li>setting the attribute to null</li>
  </ol>
  <pre><code>attr(my.list[[&quot;my.df&quot;]][[&quot;my.variable&quot;]], &quot;label&quot;) &lt;- NULL
  </code></pre>
  <ol start="6">
  <li>as.character</li>
  </ol>
  <pre><code>as.character(my.list[[&quot;my.df&quot;]][[&quot;my.variable&quot;]])
  </code></pre>
  <p>Does anyone have any ideas? Could it be a bug in R, or is it just my relative inexperience with R showing?</p>
  <p>I have also tried modifying these functions in case I was misinterpreting the label and it was value labels instead of variable labels causing the issue. It's not!</p>
  <p>Thanks for any assistance!</p>