With the code below I can export my different sized lists.

write.xlsx(as.data.frame(do.call("cbind",list(unlist(lists)))),"lists.xlsx")

I have many this kind lists in my global environment. To export all of them I tried this:

files <- mget(ls())

for (i in 1:length(files)){
  write.xlsx(as.data.frame(do.call("cbind",list(unlist(files[[i]])))), paste(names(files[i]), ".xlsx", sep = ""))
}

But when I tried this, I got an error;

Error in as.character(value) : cannot coerce type 'closure' to vector of type 'character' In addition: Warning message: In is.na(value) : is.na() applied to non-(list or vector) of type 'closure'

How can I export all this kind lists to my working directory?

0 Answers