To find the length of a string in R, you can use the nchar() function as follows:
nchar("String")
Output:
[1] 6
To find the length of multiple strings and exclude NA’s, you can use the stri_length() function from the stringi package as follows:
stri_length(c("String","Count",NA))
Output:
[1] 6 5 NA