Skip to content
Prev 377773 / 398502 Next

Combine lists into a data frame or append them to a text file

I tried Jim's function and it works. But here is an example just in case.

AA <- list(a=c(1,2,3,4),b = c("a","b","c"))
BB <- list(c=c(1,2,3,4,5),d=c("a","b","c","d","e"))
mylist <- (list(AA,BB))

lapply(mylist,function(x) write.table(x,file = test.txt))
 Show Traceback

 Error in (function (..., row.names = NULL, check.rows = FALSE,
check.names = TRUE,  :
  arguments imply differing number of rows: 4, 3
On Sun, Dec 16, 2018 at 8:45 AM Ek Esawi <esawiek at gmail.com> wrote:
Message-ID: <CA+ZkTxshnFf2uZP-5H9Ybx9ZtEvtuG-X6vo299tnt0NkAtjP_A@mail.gmail.com>
In-Reply-To: <CA+ZkTxtjLSYQJ+-3mX_NAnOUJ--9EL_dkmj3pWEaSdEbauVqgg@mail.gmail.com>