How to Check whether Characters are in String in R (Example Code)
This article illustrates how to identify whether a character is contained in a string in the R programming language.
Creating Exemplifying Data
my_string <- "YAYAYAYAYAUYAYA" # Creating character string my_string # Returning character string # "YAYAYAYAYAUYAYA" |
my_string <- "YAYAYAYAYAUYAYA" # Creating character string my_string # Returning character string # "YAYAYAYAYAUYAYA"
Example: Testing whether Character is Contained in String [grepl Function]
grepl("YAU", my_string) # Using grepl() function in R # TRUE |
grepl("YAU", my_string) # Using grepl() function in R # TRUE
Related Tutorials & Further Resources
You may find some related R tutorials on topics such as character strings and extracting data below: