I have a list object of NULL and I would like to convert it as vector NULL. How to get around with it? Many thanks in advance.
myList <- list('A' = NULL, 'B'= NULL, 'C'= NULL); myList
Expected Answer
A <- B <- C <- NULL
>Solution :
The input already is a vector of NULL values
is.vector(myList)
## [1] TRUE
sapply(myList, is.null)
## A B C
## TRUE TRUE TRUE
so we assume that the question is asking to create objects A, B and C in the global environment with the values that the components of those names have in myList. (If the current environment could be different from the global environment and you wanted them assigned into the current environment then use environment() as the second argument, instead.)
list2env(myList, .GlobalEnv)