From 8e0d433dfc2fb9d2d9d221a3c2dbcf3c24caf0fe Mon Sep 17 00:00:00 2001 From: dscott Date: Fri, 29 Jan 2016 02:03:05 +0000 Subject: [PATCH] Removed format.ftable.R and format.ftable.Rd git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@106 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- pkg/R/format.ftable.R | 99 ---------------------------------------- pkg/man/format.ftable.Rd | 66 --------------------------- 2 files changed, 165 deletions(-) delete mode 100644 pkg/R/format.ftable.R delete mode 100644 pkg/man/format.ftable.Rd diff --git a/pkg/R/format.ftable.R b/pkg/R/format.ftable.R deleted file mode 100644 index 065cd3a..0000000 --- a/pkg/R/format.ftable.R +++ /dev/null @@ -1,99 +0,0 @@ -### copy of function stats:::format.ftable because unexported from stats -format.ftable <- function (x, quote = TRUE, digits = getOption("digits"), - method = c("non.compact", "row.compact", - "col.compact", "compact"), - lsep = " | ", ...) -{ - if (!inherits(x, "ftable")) - stop("'x' must be an \"ftable\" object") - charQuote <- function(s) { - if (quote && length(s)){ - paste0("\"", s, "\"") - } else { - s - } - } - makeLabels <- function(lst) { - lens <- lengths(lst) - cplensU <- c(1, cumprod(lens)) - cplensD <- rev(c(1, cumprod(rev(lens)))) - y <- NULL - for (i in rev(seq_along(lst))) { - ind <- 1 + seq.int(from = 0, to = lens[i] - 1) * - cplensD[i + 1L] - tmp <- character(length = cplensD[i]) - tmp[ind] <- charQuote(lst[[i]]) - y <- cbind(rep(tmp, times = cplensU[i]), y) - } - y - } - makeNames <- function(x) { - nmx <- names(x) - if (is.null(nmx)) { - rep_len("", length(x)) - } else { - nmx - } - } - l.xrv <- length(xrv <- attr(x, "row.vars")) - l.xcv <- length(xcv <- attr(x, "col.vars")) - method <- match.arg(method) - if (l.xrv == 0) { - if (method == "col.compact"){ - method <- "non.compact" - } else if (method == "compact") { - method <- "row.compact" - } - } - if (l.xcv == 0) { - if (method == "row.compact") { - method <- "non.compact" - } else if (method == "compact") { - method <- "col.compact" - } - } - LABS <- switch(method, - non.compact = - {cbind(rbind(matrix("", - nrow = length(xcv), - ncol = length(xrv)), - charQuote(makeNames(xrv)), - makeLabels(xrv)), - c(charQuote(makeNames(xcv)), - rep("", times = nrow(x) + 1)))}, - row.compact = - {cbind(rbind(matrix("", - nrow = length(xcv) - 1, - ncol = length(xrv)), - charQuote(makeNames(xrv)), - makeLabels(xrv)), - c(charQuote(makeNames(xcv)), - rep("", times = nrow(x))))}, - col.compact = - {cbind(rbind(cbind(matrix("", - nrow = length(xcv), - ncol = length(xrv) - 1), - charQuote(makeNames(xcv))), - charQuote(makeNames(xrv)), - makeLabels(xrv)))}, - compact = - {xrv.nms <- makeNames(xrv) - xcv.nms <- makeNames(xcv) - mat <- - cbind(rbind(cbind(matrix("", - nrow = l.xcv - 1, - ncol = l.xrv - 1), - charQuote(makeNames(xcv[-l.xcv]))), - charQuote(xrv.nms), makeLabels(xrv))) - mat[l.xcv, l.xrv] <- paste(tail(xrv.nms, 1), - tail(xcv.nms, 1), - sep = lsep) - mat}, - stop("wrong method")) - DATA <- rbind(if (length(xcv)) t(makeLabels(xcv)), - if (method %in% c("non.compact", "col.compact")) - { rep("", times = ncol(x)) }, - format(unclass(x), digits = digits, ...) ) - cbind(apply(LABS, 2L, format, justify = "left"), - apply(DATA, 2L, format, justify = "right")) -} diff --git a/pkg/man/format.ftable.Rd b/pkg/man/format.ftable.Rd deleted file mode 100644 index 962af8c..0000000 --- a/pkg/man/format.ftable.Rd +++ /dev/null @@ -1,66 +0,0 @@ -%% File src/library/stats/man/read.ftable.Rd -%% Part of the R package, https://www.R-project.org -%% Copyright 1995-2014 R Core Team -%% Copyright 2002-2013 The R Foundation -%% Distributed under GPL 2 or later - -%% Copied to document copy of unexported function format.ftable - -\name{format.ftable} -\title{Format Flat Contingency Tables} -\alias{format.ftable} -\description{ - Format \sQuote{flat} contingency tables. -} -\usage{ -\method{format}{ftable}(x, quote = TRUE, digits = getOption("digits"), - method = c("non.compact", "row.compact", - "col.compact", "compact"), - lsep = " | ", \dots) -} -\arguments{ - \item{x}{an object of class \code{"ftable"}.} - \item{quote}{a character string giving the set of quoting characters - for \code{read.ftable}; to disable quoting altogether, use - \code{quote=""}. For \code{write.table}, a logical indicating - whether strings in the data will be surrounded by double quotes.} - \item{digits}{an integer giving the number of significant digits to - use for (the cell entries of) \code{x}.} - \item{method}{string specifying how the \code{"ftable"} object is formatted - (and printed if used as in \code{write.ftable()} or the \code{print} - method). Can be abbreviated. Available methods are (see the examples): - \describe{ - \item{"non.compact"}{the default representation of an - \code{"ftable"} object.} - \item{"row.compact"}{a row-compact version without empty cells - below the column labels.} - \item{"col.compact"}{a column-compact version without empty cells - to the right of the row labels.} - \item{"compact"}{a row- and column-compact version. This may imply - a row and a column label sharing the same cell. They are then - separated by the string \code{lsep}.} - } - } - \item{lsep}{only for \code{method = "compact"}, the separation string - for row and column labels.} - \item{\dots}{further arguments such as \code{method}, passed to - \code{format()}.} -} -\details{ - This format method is a copy of \code{format.ftable} from - \pkg{stats}, and this man page is derived from the page - \code{\link[stats]{read.ftable}}. -} -\seealso{ - \code{\link[stats]{ftable}} and - \code{\link[stats]{read.ftable}} for more information on flat - contingency tables. -} -\examples{ -ft22 <- ftable(Titanic, row.vars = 2:1, col.vars = 4:3) -write.ftable(ft22, quote = FALSE) -write.ftable(ft22, quote = FALSE, method="row.compact") -write.ftable(ft22, quote = FALSE, method="col.compact") -write.ftable(ft22, quote = FALSE, method="compact") -} -\keyword{category} -- 2.39.2