given a character vector:
myvec <- c("one", "two", "three")
I would like to turn it into a list such that names of the elements of the list come from the character vector and the list itself is empty. Note that I do not know the length of the character vector a priori. I need this because later on I programatically fill in each element of this list.
My desired output:
str(mylist)
$one
NULL
$two
NULL
$three
NULL
I came up with this:
turnList <- function(x){map(as.list(set_names(x)), ~NULL)}
And it works and all is well but I have a feeling it can be done more simply...? Solutions with purrr and tidyverse in general would be ideal...