getfirst | R Documentation |
This function retrieves the first n
elements of a vector or list.
getfirst(x, n = 1)
## Default S3 method:
getfirst(x, n = 1)
x |
A vector, list, or other supported data type. |
n |
An integer specifying the number of elements to retrieve from the start. Default is 1. |
The first n
elements of the input.
# Get the first element of a vector
getfirst(c(1, 2, 3, 4, 5))
# Get the first 2 elements of a vector
getfirst(c(1, 2, 3, 4, 5), 2)
# Get the first element of a list
getfirst(list("a", "b", "c"))
# Get the first 2 elements of a list
getfirst(list("a", "b", "c"), 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.