On Wed, 5 Feb 2020 09:15:16 -0600 Ana Marija <sokovic.anamar...@gmail.com> wrote:
> I tried to solve the task via following code: > all_results <- lapply(manyorders, function(ord) { # ... > list(fit = fit, y1 = y1) > }) > and I wrote all_results in a file > write.table(all_results, file="all_res", sep = " ", row.names = FALSE, > col.names = TRUE,quote=FALSE) all_results is a list of lists of pairs of data.frames and MArrayLM S3 objects, while write.table works best with data.frames (or things that make sense when coerced to a data.frame). I am afraid that the result of coercing a list of lists of lists into a data.frame may not make sense. What do you need the "all_res" file for? If you just want persistence (save the data between runs of R programs, but not examine it manually), consider using saveRDS/readRDS instead. If you need to interoperate with non-R programs or want a text file for transparency reasons, read on. > when I tried to open the file: > > a=read.table("all_res", header=T) > Error in read.table("all_res", header = T) : > more columns than column names Do any of the strings stored in all_results contain spaces? (y1[,'genelist'] might.) A combination of sep=" " and quote=FALSE could make such data impossible to read back unambiguously. Does it help to re-enable quote=TRUE or switch to a different sep (like "\t") that's guaranteed to be absent from strings you are trying to save? Either way, read.table() will not reconstruct the same all_results that was fed to write.table() previously unless all_results is already a data.frame (which it isn't). -- Best regards, Ivan ______________________________________________ R-help@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.