length()
   get_help() docs


Description

The length() function comes with R and is part of the Base R {base} package.

We use this function to determine the length of a value or variable, most commonly of array or list. Note that this function WILL NOT tell you the length of a string (i.e., how many characters it contains); instead, use nchar() to ask how long a string is.

Conceptual Usage

length(array to find the length of)

Examples

# Find the length of an array directly
length( c(44, 55, 66) )
## [1] 3


# Find the length of an array which has been defined as a variable
my_array <- c(44, 55, 66)
length(my_array)
## [1] 3


## CAUTION! length() does not work properly to find the number of characters in a string
length("R thinks this string is a single value in an array of length 1")
## [1] 1