I am trying length() to find the number of characters in a string, but it does not return the correct value.What function should I use to find the length of a string in R?

If you want to find the number of characters in a string, you can use the R function nchar().

> a="Hello world!!"> nchar(a)[1] 13