I created a table like this: Analysis of Variance Table Response: dati Df Sum Sq Mean Sq F value Pr(>F) groups 2 114 57.00 76 4.134e-11 *** Residuals 24 18 0.75 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 and saved it to a variable called k. When I tried to save the variable to txt file using dput(k, file = "..\\Readouts\\anova_spike_number.txt") or lapply(k, write, "..\\Readouts\\anova_spike_number.txt", append=TRUE) it destroys the formatting. Then I saved to rds using saveRDS(k, "..\\Readouts\\anova_spike_number.rds") and the format was preserved. I would like to convert the rds to txt preserving the table format. Or save it as excel file or pdf would also be fine. (If there is a way to avoid passing through rds file better, but still OK using rds). Thank you very much. Best regards, Alberto -- View this message in context: http://r.789695.n4.nabble.com/save-rds-as-text-tp4670925.html Sent from the R help mailing list archive at Nabble.com.
You might want to have a look at the xtable package John Kane Kingston ON Canada> -----Original Message----- > From: ac331 at le.ac.uk > Sent: Fri, 5 Jul 2013 03:44:02 -0700 (PDT) > To: r-help at r-project.org > Subject: [R] save rds as text > > I created a table like this: > > Analysis of Variance Table > > Response: dati > Df Sum Sq Mean Sq F value Pr(>F) > groups 2 114 57.00 76 4.134e-11 *** > Residuals 24 18 0.75 > --- > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > and saved it to a variable called k. > > When I tried to save the variable to txt file using > > dput(k, file = "..\\Readouts\\anova_spike_number.txt") > > or > > lapply(k, write, "..\\Readouts\\anova_spike_number.txt", append=TRUE) > > it destroys the formatting. > > Then I saved to rds using > > saveRDS(k, "..\\Readouts\\anova_spike_number.rds") > > > and the format was preserved. > > I would like to convert the rds to txt preserving the table format. Or > save > it as excel file or pdf would also be fine. > (If there is a way to avoid passing through rds file better, but still > OK > using rds). > > Thank you very much. > > Best regards, > > > Alberto > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/save-rds-as-text-tp4670925.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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.____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more!
Perhaps sink(file="mytable.txt") print(k) sink() gives the desired result. Best, Ista On Fri, Jul 5, 2013 at 6:44 AM, alR <ac331 at le.ac.uk> wrote:> I created a table like this: > > Analysis of Variance Table > > Response: dati > Df Sum Sq Mean Sq F value Pr(>F) > groups 2 114 57.00 76 4.134e-11 *** > Residuals 24 18 0.75 > --- > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > and saved it to a variable called k. > > When I tried to save the variable to txt file using > > dput(k, file = "..\\Readouts\\anova_spike_number.txt") > > or > > lapply(k, write, "..\\Readouts\\anova_spike_number.txt", append=TRUE) > > it destroys the formatting. > > Then I saved to rds using > > saveRDS(k, "..\\Readouts\\anova_spike_number.rds") > > > and the format was preserved. > > I would like to convert the rds to txt preserving the table format. Or save > it as excel file or pdf would also be fine. > (If there is a way to avoid passing through rds file better, but still OK > using rds). > > Thank you very much. > > Best regards, > > > Alberto > > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/save-rds-as-text-tp4670925.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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.