Finding the length of string in R programming – nchar() method

method in R programming is used to get the length of a string.**nchar()**

Syntax:`nchar(string)`

Return:Returns the length of a string.

**Example 1:**

`# R program to calculate length of string` ` ` `# Given String` `gfg <` `-` `"Geeks For Geeks"` ` ` `# Using nchar() method` `answer <` `-` `nchar(gfg)` ` ` `print` `(answer)` |

**Output:**

[1] 15

**Example 2:**

`# R program to calculate length of string` ` ` `# Given String` `gfg <` `-` `"The quick brown fox jumps over the lazy dog"` ` ` `# Using nchar() method` `answer <` `-` `nchar(gfg)` ` ` `print` `(answer)` |

**Output:**

[1] 43