prepend_object | R Documentation |
Prepend to a given list, while considering as a single object and not unlisting. Argument order is reversed compared to base::append or purrr::prepend to allow a different pattern of use in a pipe.
prepend_object(x, .l, name = NULL, before = 1)
x |
Object to prepend. If the object is a list, then it is appended as-is, and not unlisted. |
.l |
The list to append to. Special case handling applies if .l does not exist: then an empty list is used. This alleviates the need for an initial mylist <- list() |
name |
Will be used as name of the object in the list |
before |
Prepend before this index |
The list .l with x prepended
#' library(tibble) library(magrittr) library(dplyr) results <- list(second=list(1,2), third=list(3)) list(-1, 1) %>% prepend_object(results, "first") -> results # results has length 3, containing three lists
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.