I am using the map function of the purrr package in R which gives as output a list. Now I would like the output to be a named list based on the input. An example is given be
We just need to name the list
list
names(output) <- input
and then extract the elements based on the name
output$a #[1] "test-a"
If this needs to be done using tidyverse
tidyverse
library(tidyverse) output <- map(input, ~paste0('test-', .)) %>% setNames(input)