From Thom@@@SOEIRO @end|ng |rom @p-hm@|r  Thu Sep  2 13:09:35 2021
From: Thom@@@SOEIRO @end|ng |rom @p-hm@|r (SOEIRO Thomas)
Date: Thu, 2 Sep 2021 11:09:35 +0000
Subject: [Rd] sep hard coded in write.ftable
In-Reply-To: <24880.39299.992900.911002@stat.math.ethz.ch>
References: <1a597120ad27455e9249bd6577ea39b2@SCWPR-EXDAG1-6A.aphm.ap-hm.fr>
 <24880.39299.992900.911002@stat.math.ethz.ch>
Message-ID: <3883f6fe98d2418ca6bdf11abc93ce2d@SCWPR-EXDAG1-6A.aphm.ap-hm.fr>

Dear Martin,

Thank you very much for your prompt feedback!

Best regards,

Thomas

-----Message d'origine-----
De?: Martin Maechler [mailto:maechler at stat.math.ethz.ch] 
Envoy??: jeudi 2 septembre 2021 11:30
??: SOEIRO Thomas
Cc?: r-devel at r-project.org
Objet?: Re: [Rd] sep hard coded in write.ftable

EMAIL EXTERNE - TRAITER AVEC PR?CAUTION LIENS ET FICHIERS

>>>>> SOEIRO Thomas
>>>>>     on Wed, 1 Sep 2021 15:01:43 +0000 writes:

    > Dear all,

    > (This is a follow up of a previous suggestion for ftable that was added in R 4.1.0: https://urldefense.com/v3/__https://stat.ethz.ch/pipermail/r-devel/2020-May/079451.html__;!!JQ5agg!KmMY870t4h88LdWZEtwjGSopF57R5zxrL05DHa6nECGqI5_nFYUsC3OJoOzD0LQYZLOR$ )

    > The sep argument is hard coded in write.ftable:

    > write.ftable <- function(x, file = "", quote = TRUE, append = FALSE,
    > digits = getOption("digits"), ...)
    > {
    > r <- format.ftable(x, quote = quote, digits = digits, ...)
    > cat(t(r), file = file, append = append,
    > sep = c(rep(" ", ncol(r) - 1), "\n"))
    > invisible(x)
    > }

    > A minor change would allow users to modify it:

    > write.ftable2 <- function(x, file = "", quote = TRUE, append = FALSE,
    > digits = getOption("digits"), sep = " ", ...)
    > {
    > r <- stats:::format.ftable(x, quote = quote, digits = digits, ...)
    > cat(t(r), file = file, append = append,
    > sep = c(rep(sep, ncol(r) - 1), "\n"))
    > invisible(x)
    > }

I agree this sounds reasonable, and am currently running 'make check-devel' on sources modified accordingly ..

Martin


    > This would allow to avoid a previous call to format.ftable (although write.ftable is significantly slower than write.table):

    > ftable(formula = wool + tension ~ breaks, data = warpbreaks) |>
    > format(quote = FALSE) |>
    > write.table(sep = ";", row.names = FALSE, col.names = FALSE)

    > ftable(formula = wool + tension ~ breaks, data = warpbreaks) |>
    > write.ftable2(sep = ";")

    > Best regards,
    > Thomas

    > ______________________________________________
    > R-devel at r-project.org mailing list
    > https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-devel__;!!JQ5agg!KmMY870t4h88LdWZEtwjGSopF57R5zxrL05DHa6nECGqI5_nFYUsC3OJoOzD0M93CBRa$


[Rd] sep hard coded in write.ftable
SOEIRO Thomas