Hi everyone, question on using an If Else command with text in R. What I'm trying to do is tell R to look at a column and, if the text in that column equals what is in another column to pull a numerical figure from a third column, and if it doesn't to pull a different numerical value. For example, I'm working with football data and want the system to detect is "Minnesota Vikings" is present in the column I direct. The syntax I'm using, with a mutate command to create a new column, is below:
mutate(cover=(ifelse("team_home"=="Longform Name", spread, "spread_favorite")))
Problem is, R doesn't detect that the team names in text match, it is treating everything as though it doesn't match even though tidyverse is loaded up. I checked in excel and according to that, the text does match (ruling out any spacing issues or anything like that). Any suggestions or ideas? I can manipulate my original data from excel to get the output i want without having to match anything but would prefer to figure out why R isn't detecting a match. Thanks!