Cross-tabulation for a pair of categorical variables (or factors) with either row, column, or total proportions, as well as marginal sums.
ctable(x, y, prop = st_options("ctable.prop"), useNA = "ifany",
totals = st_options("ctable.totals"), style = st_options("style"),
round.digits = 1, justify = "right",
omit.headings = st_options("omit.headings"),
plain.ascii = st_options("plain.ascii"), split.tables = Inf,
dnn = c(substitute(x), substitute(y)), ...)
First categorical variable - values will appear as row names.
Second categorical variable - values will appear in as column names.
Proportions to display; “r” for rows (default),
“c” for columns, “t” for total, or “n” for
none. This option can be set globally; see st_options
.
Argument passed on to table
; One of “ifany”
(default), “no”, or “always”.
Logical. Should row and column totals be displayed? Defaults to TRUE
.
To change this default value globally, see st_options
.
Style to be used by pander
when rendering
output table; One of “simple” (default), “grid”, or “rmarkdown”
This option can be set globally; see st_options
.
Number of significant digits to display. Defaults to
1
. To change this default value globally, see st_options
.
String indicating alignment of columns; one of “l” (left) “c” (center), or “r” (right). Defaults to “r”.
Logical. Set to TRUE
to omit heading section. Can be set
globally via st_options
.
Logical. pander
argument; when
TRUE
, no markup characters will be used (useful when printing
to console). Defaults to TRUE
unless style = 'rmarkdown'
,
in which case it will be set to FALSE
automatically. To change the default
value globally, see st_options
.
Pander argument that specifies how many characters wide a
table can be. Inf
by default.
Names to be used in output table. Vector of two strings; By default, the character values for arguments x and y are used.
Additional arguments passed to pander
.
A frequency table of class matrix
with added attributes used
by print method.
Rmarkdown does not, to this day, support multi-header tables. Therefore, until such support is available, the recommended way to display cross-tables in .Rmd documents is to use `method=render` with the `print()` generic function or with the `view()` function. See package vignettes for examples.
# NOT RUN {
data("tobacco")
ctable(tobacco$gender, tobacco$smoker)
# }
Run the code above in your browser using DataLab