From Thom@@@SOEIRO @end|ng |rom @p-hm@|r  Wed Sep  1 17:01:43 2021
From: Thom@@@SOEIRO @end|ng |rom @p-hm@|r (SOEIRO Thomas)
Date: Wed, 1 Sep 2021 15:01:43 +0000
Subject: [Rd] sep hard coded in write.ftable
Message-ID: <1a597120ad27455e9249bd6577ea39b2@SCWPR-EXDAG1-6A.aphm.ap-hm.fr>

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)
}

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



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