[Rd] sep hard coded in write.ftable

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Thu Sep 2 11:29:39 CEST 2021


>>>>> 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://stat.ethz.ch/pipermail/r-devel/2020-May/079451.html)

    > 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 using r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list