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"

Example: Find Positions of Every Dot in Character String

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:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top