Error in R with list2env function

3

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?

    
asked by anonymous 28.08.2018 / 20:22

1 answer

4

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" 
    
04.01.2019 / 23:25