named_list: Create a list with items named based on the names of...

named_listR Documentation

Create a list with items named based on the names of variables passed to the function

Description

Not infrequently, you might find yourself writing things like list(var1 = var1, var2 = var2). This function makes this easier by creating a list with items named based on the variables passed into it.

Usage

named_list(...)

Arguments

...

One or more variables to be included into a list. Note that you can pass values as well, but they are then used as both the name and the value of the respective list item.

Value

A named list, with names taken from the variable names in the input

Examples

name <- "Paul"
age <- 10
named_list(name, age)

# Note that this can be combined with named arguments
named_list(name, age, place = "Berlin")


LukasWallrich/timesaveR documentation built on Nov. 29, 2024, 4:47 a.m.