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 = "r", useNA = "ifany", totals = TRUE,
style = "simple", round.digits = 1, justify = "right",
omit.headings = FALSE, plain.ascii = TRUE, split.table = 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.
Argument passed on to table; One of “ifany”
(default), “no”, or “always”.
Logical. Should row and column totals be displayed? Defaults to TRUE.
Style to be used by pander when rendering
output table; One of “simple” (default), “grid” or
Number of significant digits to display. Defaults to
1.
“rmarkdown”.
String indicating alignment of columns; one of “l” (left) “c” (center), or “r” (right). Defaults to “r”.
Logical. Set to TRUE to omit headings.
Logical. pander argument; when
TRUE, no markup characters will be used (useful when printing
to console). Defaults to TRUE when style is “simple”,
and FALSE otherwise.
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.
The default plain.ascii = TRUE option is there to make results
appear cleaner in the console. To avoid rmarkdown rendering problems, the
option is automatically set to FALSE whenever
style = "rmarkdown", unless plain.ascii = TRUE is made
explicit.
# NOT RUN {
data("tobacco")
ctable(tobacco$gender, tobacco$smoker)
# }
Run the code above in your browser using DataLab