title: Change value based on match to comma-separated list in a seperate dataframe
body: <p>So I'm working with two different dataframes in R. One with user information and one with company information.</p>
  <pre><code>user &lt;- data.frame(User_ID = 1:4, company = c(&quot;Ford&quot;, &quot;Ford Motors&quot;, &quot;Ford China&quot;, &quot;amazon.com&quot;))
  
  company_info &lt;- data.frame(company_ID = 1:2, company_name = c(&quot;Ford&quot;, &quot;Amazon&quot;), company_name_other =  c(&quot;Ford Motors, Ford China&quot;, &quot;amazon.com, Amazon AWS&quot;))
  </code></pre>
  <p>The goal is to change <code>user$company</code> value if it is found in the comma-separated list in <code>company_info$company_name_other</code> column -- I want to change it to the value in the <code>company_info$company_name</code> column. So the goal here would be to change <strong>all</strong> the company values in the user dataframe to be either &quot;Ford&quot; or &quot;Amazon&quot;</p>
  <p>I tried the following code:</p>
  <pre><code>user %&gt;% 
     mutate(company = ifelse(str_detect(company_info$company_name_other, company), company_info$company_name, company))
  </code></pre>
  <p>This changed three of the rows, but not the Ford Motor entry? What should I be tweaking?</p>