title: Using dplyr's mutate based on str_detect
body: <p>I'm attempting to assign team values to each player in my data frame based on whether they're included in the "home_lineup" or "away_lineup" character strings.</p>
  
  <p>I've used the <code>str_detect</code> function and beyond that, I haven't found alternate ways to approach the problem. </p>
  
  <p>Included in this link is a snapshot of the data frame, which would have the season_data_select assignment. </p>
  
  <pre><code>library(gsheet)
  url &lt;- 'https://docs.google.com/spreadsheets/d/1Z1njK5FxCZgIUaxxoRUVaK8DFNWP4OGthT6kuFHcC7I/edit?usp=sharing'
  season_data_select  &lt;- gsheet2tbl(url)
  </code></pre>
  
  <p><a href="https://docs.google.com/spreadsheets/d/1Z1njK5FxCZgIUaxxoRUVaK8DFNWP4OGthT6kuFHcC7I/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1Z1njK5FxCZgIUaxxoRUVaK8DFNWP4OGthT6kuFHcC7I/edit?usp=sharing</a></p>
  
  <pre><code>library(dplyr)
  season_data_select &lt;- season_data_select %&gt;% 
                        mutate(player_team = ifelse(str_detect(player, home_lineup), 
                              home, 
                              away))
  </code></pre>
  
  <p>Ideally, I am looking a code that will introduce a new column (player_team) that will take the value in the "player" column and check to see if it is in the "home_lineup" column. If it is, then return the value in the "home" column. If not, return the "away" column value. Alternatively, I could see it being "if in 'home_lineup', return 'home', if in 'away_lineup', return 'away'"</p>
  
  <p>When used, the current code returns the value in away, which leads me to believe there is an issue when trying to reference the 'home_lineup' column with the 'player' value. All of the involved variables are in the character class.</p>