Subsetting Data

It is not a good idea to put your data in the screenshot like this. Here you can find what you should do instead:

This way it'll be much easier to others to help you.

I think, both of your questions can be answered with stringr package, specifically stringr::str_detect().