I am trying to create a named nested list, something like:
list(
list(id = 1, name = "Abbie"),
list(id = 2, name = "Benjamin")
# ... more list statements here
)
I have created the nested list structure using purrr::map2:
c("Abbie", "Benjamin") %>%
map2(seq(.), ., list)
However, how do I then name the list with purrr?
Note: From this question I experimented with the following, which does not do what I'm looking for:
c("Abbie", "Benjamin") %>%
map2(seq(.), ., list) %>%
set_names(paste0("ID", seq(.)))
mapc("Abbie", "Benjamin") %>% set_names(., seq_along(.)) %>% as.list- akrun