Find Positions of Dots in Character String in R (3 Examples) | Locate Position | gregexpr & unlist

preview_player
Показать описание
R code of this video:

my_string # Print example character string

all_dots <- unlist(gregexpr("\\.", my_string)) # Get all dot locations
all_dots # Return all dot locations

first_dot <- all_dots[1] # Extract first dot position
first_dot # Print first dot position

last_dot <- all_dots[length(all_dots)] # Extract last dot position
last_dot # Print last dot position

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

I'm curious about how this is commonly used. Once you know the location of the characters you are looking for, what do you do with that?

douglaspage