Question :
I try to convert my list (which contains 12 dataframes and approximately 20,000 lines each) into separate dataframes:
list2env(mylist,envir=.GlobalEnv)
but the following error message appears:
names(x) must be a character vector of the same length as x
What can it be and what to do?
Answer :
As noted by @RuiBarradas, the list should be named so that it can be transformed into an environment.
Reproducing the error:
mylist <- list(1, 2, "a")
list2env(mylist,envir=.GlobalEnv)
# Error in list2env(mylist, envir = .GlobalEnv) :
# names(x) deve ser um vetor de caracter de mesmo comprimento que x
Applying the solution we have
names(mylist) <- paste("membro", seq_along(mylist), sep = ".")
ls()
# [1] "mylist"
list2env(mylist,envir=.GlobalEnv)
# <environment: R_GlobalEnv>
ls()
# [1] "membro.1" "membro.2" "membro.3" "mylist"