The “length” Function in R
Package: Base R (no specific package required)
Purpose: Returns the number of elements in a vector or the number of components in an object.
General Class: Utility/Basic
Required Argument(s):
x: A vector or an object.
Notable Optional Arguments:
None
Example:
# Example vector
data <- c(2, 4, 6, 8, 10)
# Get the length of the vector
result <- length(data)
print(result)In this example, the length function is used to get the number of elements in the numeric vector data. The result is then printed to the console.