append_object: Appending in a pipe, never unlisting

Description Usage Arguments Value Examples

View source: R/purrr-like.R

Description

Append to a given list, while considering as a single object and not unlisting as base::append does. Argument order is reversed compared to base::append to allow a different pattern of use in a pipe.

Usage

1

Arguments

x

Object to append. 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

Value

The list .l with x appended

Examples

1
2
3
4
5
6
library(magrittr)
results <- list(first=c(3,4), second=list(5,6))
list(7,8) %>%
  append_object(results, "third result") ->
results
# results has length 1, containing one list named "first"

tidytidbits documentation built on March 8, 2021, 5:07 p.m.