On Mar 16, 2006, at 9:48 PM, Stephen D. Weigand wrote:
I would like to suggest that an 'append' argument be added to
write.ftable(). This would allow, for example, the user to
append ftable() output to a text report.
I have attached an svn patch to ftable.R that makes the proposed
change to write.ftable(). [A very trivial change since 'append'
is simply passed to cat().]
I have also attached a patch to read.ftable.Rd which documents
the proposed argument (borrowing from cat.Rd).
The text-based patch files were attached but had extensions *.patch.
I'm resending them with *.txt extensions in case that's necessary.
Index: R/src/library/stats/R/ftable.R
===================================================================
--- R/src/library/stats/R/ftable.R (revision 37549)
+++ R/src/library/stats/R/ftable.R (working copy)
@@ -151,7 +151,7 @@
x
}
-write.ftable <- function(x, file = "", quote = TRUE,
+write.ftable <- function(x, file = "", append = FALSE, quote = TRUE,
digits = getOption("digits"))
{
if(!inherits(x, "ftable"))
@@ -191,7 +191,8 @@
format(unclass(x), digits = digits))
x <- cbind(apply(LABS, 2, format, justify = "left"),
apply(DATA, 2, format, justify = "right"))
- cat(t(x), file = file, sep = c(rep(" ", ncol(x) - 1), "\n"))
+ cat(t(x), file = file, append = append,
+ sep = c(rep(" ", ncol(x) - 1), "\n"))
invisible(ox)
}
Index: R/src/library/stats/man/read.ftable.Rd
===================================================================
--- R/src/library/stats/man/read.ftable.Rd (revision 37549)
+++ R/src/library/stats/man/read.ftable.Rd (working copy)
@@ -31,6 +31,10 @@
\item{skip}{the number of lines of the data file to skip before
beginning to read data.}
\item{x}{an object of class \code{"ftable"}.}
+ \item{append}{logical. If \code{TRUE} and \code{file} is the name of
+ a file (and not a connection or \code{"|cmd"}), the output from
+ \code{write.ftable} is appended to the file. If \code{FALSE},
+ the contents of \code{file} will be overwritten.}
\item{digits}{an integer giving the number of significant digits to
use for (the cell entries of) \code{x}.}
\item{\dots}{further arguments to be passed to or from methods.}
As a backup, the patches are in-line below.
Thanks again,
Stephen
Index: R/src/library/stats/R/ftable.R
===================================================================
--- R/src/library/stats/R/ftable.R (revision 37549)
+++ R/src/library/stats/R/ftable.R (working copy)
@@ -151,7 +151,7 @@
x
}
-write.ftable <- function(x, file = "", quote = TRUE,
+write.ftable <- function(x, file = "", append = FALSE, quote = TRUE,
digits = getOption("digits"))
{
if(!inherits(x, "ftable"))
@@ -191,7 +191,8 @@
format(unclass(x), digits = digits))
x <- cbind(apply(LABS, 2, format, justify = "left"),
apply(DATA, 2, format, justify = "right"))
- cat(t(x), file = file, sep = c(rep(" ", ncol(x) - 1), "\n"))
+ cat(t(x), file = file, append = append,
+ sep = c(rep(" ", ncol(x) - 1), "\n"))
invisible(ox)
}
Index: R/src/library/stats/man/read.ftable.Rd
===================================================================
--- R/src/library/stats/man/read.ftable.Rd (revision 37549)
+++ R/src/library/stats/man/read.ftable.Rd (working copy)
@@ -31,6 +31,10 @@
\item{skip}{the number of lines of the data file to skip before
beginning to read data.}
\item{x}{an object of class \code{"ftable"}.}
+ \item{append}{logical. If \code{TRUE} and \code{file} is the name of
+ a file (and not a connection or \code{"|cmd"}), the output from
+ \code{write.ftable} is appended to the file. If \code{FALSE},
+ the contents of \code{file} will be overwritten.}
\item{digits}{an integer giving the number of significant digits to
use for (the cell entries of) \code{x}.}
\item{\dots}{further arguments to be passed to or from methods.}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel