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

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