nchar Function in R (Example)

The R code on this page illustrates how to count the length of a character string with the nchar() function in the R programming language.

Example Data

my_char <- "This is an example string"     # Create example string

Example: Application of nchar Function

nchar(my_char)                             # Return length of string
# 25

The RStudio console returns the value 25. This means that our example string consists of 25 characters.

Video Examples

The following video shows further examples for the application of the nchar function in R:

YouTube

By loading the video, you agree to YouTube’s privacy policy.
Learn more

Load video

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top