How to find length of String in R

Learn how to find length of String in R using nchar(x) function with Example R Script.

Syntax of nchar function

nchar(x)

where x is of character data type

 

Find length of String in R

Example to find length of String in R

 

Example to find length of a number in R

nchar automatically type casts number to character

 

You may try nchar(c) function for other data types to find the length.

 

Conclusion :

In this R Tutorial, we have learnt to use nchar(x) to find length of string or number in R programming language.