Search code examples
rrlang

Use rlang to create a named list programmatically


from Constructing lists using tidyeval tools (like `!!` and `:=`), you can do

a <- "item_name"
b <- "item_value"

list2(!!a := b)

How could I accomplish the same thing itemwise, when there is more than one element?

a <- c("item_name1","item_name2")
b <- c("item_value1","item_value2")

Solution

  • structure(as.list(b), names=a)