splice: Splice objects and lists of objects into a list

Description Usage Arguments Value Life cycle Examples

View source: R/splice.R

Description

\Sexpr[results=rd, stage=render]{purrr:::lifecycle("questioning")}

This splices all arguments into a list. Non-list objects and lists with a S3 class are encapsulated in a list before concatenation.

Usage

1

Arguments

...

Objects to concatenate.

Value

A list.

Life cycle

splice() is in the questioning lifecycle stage as of purrr 0.3.0. We are now favouring the !!! syntax enabled by rlang::list2().

Examples

1
2
3
4
5
6
inputs <- list(arg1 = "a", arg2 = "b")

# splice() concatenates the elements of inputs with arg3
splice(inputs, arg3 = c("c1", "c2")) %>% str()
list(inputs, arg3 = c("c1", "c2")) %>% str()
c(inputs, arg3 = c("c1", "c2")) %>% str()

Example output

List of 3
 $ arg1: chr "a"
 $ arg2: chr "b"
 $ arg3: chr [1:2] "c1" "c2"
List of 2
 $     :List of 2
  ..$ arg1: chr "a"
  ..$ arg2: chr "b"
 $ arg3: chr [1:2] "c1" "c2"
List of 4
 $ arg1 : chr "a"
 $ arg2 : chr "b"
 $ arg31: chr "c1"
 $ arg32: chr "c2"

purrr documentation built on April 19, 2020, 4:17 p.m.