Skip to content

Commit

Permalink
Fixes bug in previous fix, documents use of table args in ftable.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@28250 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
murdoch committed Feb 5, 2004
1 parent fffcb83 commit 907da65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/library/stats/R/ftable.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ ftable.default <- function(..., exclude = c(NA, NaN),
x <- as.table(x)
}
else if(!(is.array(x) && (length(dim(x)) > 1))) {
names(args) <- as.character(unlist(as.list(substitute(list(...)))))[-1]
x <- do.call("table",
c(args, list(exclude = exclude)))
x <- table(..., exclude = exclude)
}
dn <- dimnames(x)
dx <- dim(x)
Expand Down
10 changes: 9 additions & 1 deletion src/library/stats/man/ftable.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ ftable(x, \dots)
given and their union is a proper subset of all variables involved,
the other variables are summed out.

When the arguments are \R expressions interpreted as factors,
additional arguments will be passed to \code{table} to control how
the variable names are displayed; see the last example below.

Function \code{\link{ftable.formula}} provides a formula method for
creating flat contingency tables.
}
Expand All @@ -82,5 +86,9 @@ data(mtcars)
x <- ftable(mtcars[c("cyl", "vs", "am", "gear")])
x
ftable(x, row.vars = c(2, 4))
}

## Start with expressions, use table()'s "dnn" to change labels
ftable(mtcars$cyl, mtcars$vs, mtcars$am, mtcars$gear, row.vars = c(2, 4),
dnn = c("Cylinders", "V/S", "Transmission", "Gears"))
}
\keyword{category}

0 comments on commit 907da65

Please sign in to comment.