title: Replace multiple words in R easily; str_replace_all gives error that two objects are not equal lengths
body: <p>I'm trying to use str_replace_all to replace many different values (i.e. "Mod", "M2", "M3", "Interviewer") with one the consistent string (i.e. "Moderator:"). I'm doing this with multiple different categories, and I want avoid having to write each unique value out as there are a lot.</p>
  
  <p>So I made a tibble consisting of all the unique values that I want to make standardized and read it in and then pulled out each column (there are 5 but only 2 shown for simplicity) to make them into vectors:</p>
  
  <pre><code>speak_names &lt;- read_csv("speak_names.csv")
  speak_namesMisc &lt;- dplyr::pull(speak_names, Misc)
  speak_namesMod &lt;- dplyr::pull(speak_names, Moderator)
  </code></pre>
  
  <p>For the replacement value, I made a character vector of equal length to those above vectors because I know that the replacement and pattern must be equal lengths:</p>
  
  <pre><code>Misc &lt;- rep("Misc:", 2)
  Mod &lt;- rep("Moderator:", 28)
  </code></pre>
  
  <p>When I run Misc through with this code, it works just fine:</p>
  
  <pre><code>atas_clean$speaker &lt;- str_replace_all(atas_clean$speaker, speak_namesMisc, Misc)
  </code></pre>
  
  <p>But when I try the identical Moderator version (even if I attempt to run it before Misc), I get an error message:</p>
  
  <pre><code>atas_clean$speaker &lt;- str_replace_all(atas_clean$speaker, speak_namesMod, 
  Mod)
  
  Warning message:
  In stri_replace_all_regex(string, pattern, fix_replacement(replacement),  :
  longer object length is not a multiple of shorter object length
  </code></pre>
  
  <p>I don't know why I'm getting this error because this identical function yields TRUE:</p>
  
  <pre><code>identical(length(speak_namesMod), length(Mod))
  </code></pre>
  
  <p>The dataframe that I'm working with is 16,244 lines long if that makes any difference to the pattern or replacement. I'm stuck and trying to find out why this isn't working and/or another solution that does not involve typing out each character element in the vectors. </p>
  
  <p>Thank you!</p>