Get All Locations of Dots in a Character String in R (Example Code)
In this R tutorial you’ll learn how to locate all dots.
Example Data
x <- "abc.d.efg.hi" # Constructing an example character string x # [1] "abc.d.efg.hi" |
x <- "abc.d.efg.hi" # Constructing an example character string x # [1] "abc.d.efg.hi"
Example: Find Positions of Every Dot in Character String
unlist(gregexpr("\.", x)) # Return dot locations # [1] 4 6 10 |
unlist(gregexpr("\.", x)) # Return dot locations # [1] 4 6 10
Further Resources & Related Tutorials
In the following, you may find some additional resources on topics such as extracting data, coding errors, and character strings: