The nchar()
function in R is used to calculate the size of a string.
The illustration below shows the mathematical representation of the nchar()
function.
nchar(string)
The nchar()
function requires a string
as a parameter.
This function returns the size of a string
.
a <- nchar("hello");print(paste0("nchar('hello): ", a))b <- nchar("educative");print(paste0("nchar('educative): ", b))