Is there a way to use mapply on two vectors to construct a named list? The first vector would be of type character and contain the names used for the list while
character
What I propose is made in 2 steps, and it's quite straightforward, so maybe it's easier to understand:
test_list <- list(1, 2) names(test_list) <- c("foo", "bar")
What @ben-bolker proposes works, but just wanted to share an alternative, in case you prefer it.
Happy coding!