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:

You are currently viewing a placeholder content from YouTube. To access the actual content, click the button below. Please note that doing so will share data with third-party providers.

More Information

Leave a Reply

Your email address will not be published. Required fields are marked *

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