View source: R/get_n_elements.R
get_n_elements | R Documentation |
Get only the first N elements from a named list.
get_n_elements(l, n = 1, simplify = TRUE, verbose = TRUE)
l |
A list. |
n |
The maximum number of elements to return from that list. |
simplify |
When the final length of the list is 1, unlist the object. |
verbose |
Print messages. |
A shortened list or a single element.
l <- lapply(seq(4),prod,3)
l1 <- get_n_elements(l, n=1)
l2 <- get_n_elements(l, n=2, simplify = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.