R Delete Part Before or After Point in Character String (Example Code)

In this article, I’ll show how to remove characters before or after points in R programming.

Creation of Example Data

my_data <- "lalala.lololo"        # Create example data
my_data                           # Print example data
# [1] "lalala.lololo"

Example: Using gsub Function & Double Backslash to Delete Characters Before or After Point

gsub("\..*", "", my_data)        # Applying gsub() function
# [1] "lalala"

Related Articles

Below, you may find some further resources on topics such as extracting data 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