[R] save rds as text

Ista Zahn istazahn at gmail.com
Sun Jul 7 01:41:12 CEST 2013


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.



More information about the R-help mailing list