Hi all,
I'm a newbie here and have spent days trying to figure out how to write this script. My data frame contains 50,000+ rows, so I definitely don't want to do this analysis manually. If you can help me write this script successfully, I'd be happy to list you by name in the acknowledgments section of the journal article I'm writing. Here's what I'm trying to accomplish:
My data frame is called followers_df
. I want to write a script that will create a new column vector called ismedia
in the data frame that would contain the word TRUE if any of the following conditions are satisfied:
• If the column vector called UserName
contains the string news
• If the column vector called UserName
contains the string tv
• If the column vector called Bio
contains the string news
• If the column vector called Bio
contains the string reporter
• If the column vector called Bio
contains the string journalist
• If the column vector called Bio
contains the string radio
• If the column vector called Bio
contains the string tv
• If the column vector called Bio
contains the string television
This is what I wrote. It was an epic fail:
I tried to write a case_when statement inside mutate to create a new variable called ismedia
that relies on one of several things in two different variables being true
mutate (ismedia = case_when (followers_df$UserName == "news | tv" , followers_df$Bio == "news|reporter|journalist|radio|tv|television")) %>%
Thank you in advance for your help!
Kim