-1

I wish to filter those of my data that contains a particular string. Let's assume this is my data set

#dst

 first    second 
  24       Sienna,Zoe,Dylan
  32       Amber,John,Noah,Sienna
  72       Daniel,Mike,Zoe 

And I wish to have only data that contains "Zoe". So, I'd like to have this output

#output 

first    second
24       Sienna,Zoe,Dylan
72       Daniel,Mike,Zoe
MFR
  • 2,049
  • 3
  • 29
  • 53

1 Answers1

1

You can use the grep or grepl factions.
If your data frame is named "dst", then this should work:

output<-dst[grep("Zoe", dst$second),]
Dave2e
  • 22,192
  • 18
  • 42
  • 50