To clarify, R is the language, and RStudio is just the IDE (see FAQ below for disambiguation). Since this question isn't about the IDE itself, I'm going to move it to General.
What you're describing sounds like a good use-case for grepl() or a similar string-matching function which:
search for matches to argument pattern within each element of a character vector