+4 votes
in Programming Languages by (5.4k points)

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?

1 Answer

0 votes
by (33.7k points)

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

...