Hello,
I want to check whether a particular string is present in a vector of strings in R. How can I do this?
Thanks
Hello,
I want to check whether a particular string is present in a vector of strings in R. How can I do this?
Thanks
You can use
match : https://stat.ethz.ch/R-manual/R-devel/library/base/html/match.html
While other methods can also be used in combination with apply methods. I find the above to be the most convenient.
example:
grep(“pattern”, vector of data)
patter is regular expression example “^Vidhya” will match any strings in your vector starting with Vidhya
Check for regular expressions ( be careful for R and Python the special characters are different)