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

Bert Gunter bgunter@4567 @ending from gm@il@com
Sun Dec 16 06:04:18 CET 2018


FWIW, I had no trouble writing a test case to a file with either version of
your code. As we have no idea what your data look like, I don't know how
anyone can diagnose the problem. But maybe I'm wrong and someone else will
recognize the issue.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Dec 15, 2018 at 7:28 PM Ek Esawi <esawiek using gmail.com> wrote:

> Hi All,
>
> I have an R object that is made up of N number of lists which are all
> of different number of columns and rows.  I want to combine the N
> lists into a single data frame or write (append) them into text file.
> I hope the question is clear and doesn’t require an example. I am
> hoping to accomplish this using base R functions.
> Below is what I tried but both gave me the same error which I do
> understand, I think, but I don’t know how to fix it. My R object is
> MyTables
>
> lapply(MyTables, function(x) write.table(x, file = "Temp.txt",append =
> TRUE ))
> OR
> for (i in 1:length(MyTables)) {
> write.table(MyTables[i], file = "Temp.txt",append = TRUE,quote = TRUE)
>
> the error
> Error in (function (..., row.names = NULL, check.rows = FALSE,
> check.names = TRUE,  :
>   arguments imply differing number of rows: 51, 8, 30
>
> Thanks--EK
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list