How to Locate the Position of a Character in a String in R (Example Code)
In this tutorial, I’ll show how to identify the location of a character in a string in R programming.
Example: Identify Position of Character in String with gregexpr & unlist Functions
unlist(gregexpr("i", "Hello this is my character string")) # Application of gregexpr & unlist functions # 9 12 31 |
unlist(gregexpr("i", "Hello this is my character string")) # Application of gregexpr & unlist functions # 9 12 31