STRING MANIPULATION IN R
String manipulation in R involves the modification, analysis and transformation of text data, including actions such as substring extraction, pattern searching, replacement, concatenation and formatting changes to strings
Count the number of characters with nchar()
nchar() nzchar()
Concatenate strings with paste() and paste0()
paste() paste0()
Print formatted values with sprintf()
sprintf()
Lowercase and uppercase with tolower() and toupper()
tolower() toupper() casefold() chartr()
Split strings with strsplit()
strsplit()
Extract and replace substrings with substring() and substr()
substring() substr()
Remove leading and/or trailing whitespaces with trimws()
trimws()
Pattern matching with grepl() and grep()
grepl() grep()
Pattern matching and replacement with gsub() and sub()
gsub() sub()