prepend_object {tidytidbits}R Documentation

Prepending in a pipe, never unlisting

Description

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.

Usage

prepend_object(x, .l, name = NULL, before = 1)

Arguments

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

Value

The list .l with x prepended

Examples

#' 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

[Package tidytidbits version 0.3.2 Index]