dimanche 26 juillet 2020

Issues with searching for specific phrases within a column in R [First Question Ever] [duplicate]

I hope everyone is doing well. I would like to preface this post by pointing out that I am very new to using R, and entirely new to the Stack Overflow community here.

I will try to follow the guidelines for posting to the best of my ability, and I apologize in advance if my question is unclear in any way.

I recently collected survey data pertaining to the recruitment trends for student-led organizations at my business school. I have collected this data using a google form, which I then exported to a CSV file and read into R.


One particular column of data "Application.Awareness" shows student responses for how they became aware of recruitment events. Responses include character strings such as "Word of Mouth" , "Email", and "Social Media".

Students may select more than one option when answering, so many of my rows look like:

Word of Mouth, Social Media

Social Media, Email, Word of Mouth

Word of Mouth

Social Media, Email

Email


My Issue

I want to create separate columns for Social Media, Word of Mouth, and Email, so that I can easily measure and compare the popularity of these three options.

To do so, I have tried to utilize the IfElse arugment, which I thought would mark rows that contain "Email" with a "1".

MyData$App.Awareness.Email <- ifelse(MyData$Application.Awareness == "Email",1,0)

However, this code only works for rows of data which ONLY contain the response "Email". For example, a response containing "Email, Social Media" will result in a "0" in the new column.

My Question

Based on the problem above, is there a way to pull the observations that contain the word "Email", even if there are other words/phrases in the same row?

I hope I am articulating this well, please let me know if you need me to explain further. Thank you to anyone who has taken the time to read this!

Aucun commentaire:

Enregistrer un commentaire