tab_xtab | R Documentation |
Shows contingency tables as HTML file in browser or viewer pane, or saves them as file.
tab_xtab(
var.row,
var.col,
weight.by = NULL,
title = NULL,
var.labels = NULL,
value.labels = NULL,
wrap.labels = 20,
show.obs = TRUE,
show.cell.prc = FALSE,
show.row.prc = FALSE,
show.col.prc = FALSE,
show.exp = FALSE,
show.legend = FALSE,
show.na = FALSE,
show.summary = TRUE,
drop.empty = TRUE,
statistics = c("auto", "cramer", "phi", "spearman", "kendall", "pearson", "fisher"),
string.total = "Total",
digits = 1,
tdcol.n = "black",
tdcol.expected = "#339999",
tdcol.cell = "#993333",
tdcol.row = "#333399",
tdcol.col = "#339933",
emph.total = FALSE,
emph.color = "#f8f8f8",
prc.sign = " %",
hundret = "100.0",
CSS = NULL,
encoding = NULL,
file = NULL,
use.viewer = TRUE,
remove.spaces = TRUE,
...
)
sjt.xtab(
var.row,
var.col,
weight.by = NULL,
title = NULL,
var.labels = NULL,
value.labels = NULL,
wrap.labels = 20,
show.obs = TRUE,
show.cell.prc = FALSE,
show.row.prc = FALSE,
show.col.prc = FALSE,
show.exp = FALSE,
show.legend = FALSE,
show.na = FALSE,
show.summary = TRUE,
drop.empty = TRUE,
statistics = c("auto", "cramer", "phi", "spearman", "kendall", "pearson", "fisher"),
string.total = "Total",
digits = 1,
tdcol.n = "black",
tdcol.expected = "#339999",
tdcol.cell = "#993333",
tdcol.row = "#333399",
tdcol.col = "#339933",
emph.total = FALSE,
emph.color = "#f8f8f8",
prc.sign = " %",
hundret = "100.0",
CSS = NULL,
encoding = NULL,
file = NULL,
use.viewer = TRUE,
remove.spaces = TRUE,
...
)
var.row |
Variable that should be displayed in the table rows. |
var.col |
Cariable that should be displayed in the table columns. |
weight.by |
Vector of weights that will be applied to weight all cases.
Must be a vector of same length as the input vector. Default is
|
title |
String, will be used as table caption. |
var.labels |
Character vector with variable names, which will be used to label variables in the output. |
value.labels |
Character vector (or |
wrap.labels |
Numeric, determines how many chars of the value, variable or axis labels are displayed in one line and when a line break is inserted. |
show.obs |
Logical, if |
show.cell.prc |
Logical, if |
show.row.prc |
Logical, if |
show.col.prc |
Logical, if |
show.exp |
Logical, if |
show.legend |
logical, if |
show.na |
logical, if |
show.summary |
Logical, if |
drop.empty |
Logical, if |
statistics |
Name of measure of association that should be computed. May
be one of |
string.total |
Character label for the total column / row header |
digits |
Amount of decimals for estimates |
tdcol.n |
Color for highlighting count (observed) values in table cells. Default is black. |
tdcol.expected |
Color for highlighting expected values in table cells. Default is cyan. |
tdcol.cell |
Color for highlighting cell percentage values in table cells. Default is red. |
tdcol.row |
Color for highlighting row percentage values in table cells. Default is blue. |
tdcol.col |
Color for highlighting column percentage values in table cells. Default is green. |
emph.total |
Logical, if |
emph.color |
Logical, if |
prc.sign |
The percentage sign that is printed in the table cells, in HTML-format.
Default is |
hundret |
Default value that indicates the 100-percent column-sums (since rounding values
may lead to non-exact results). Default is |
CSS |
A |
encoding |
String, indicating the charset encoding used for variable and
value labels. Default is |
file |
Destination file, if the output should be saved as file.
If |
use.viewer |
Logical, if |
remove.spaces |
Logical, if |
... |
Other arguments, currently passed down to the test statistics functions
|
Invisibly returns
the web page style sheet (page.style
),
the web page content (page.content
),
the complete html-output (page.complete
) and
the html-table with inline-css for use with knitr (knitr
)
for further use.
# prepare sample data set
data(efc)
# print simple cross table with labels
## Not run:
if (interactive()) {
tab_xtab(efc$e16sex, efc$e42dep)
# print cross table with manually set
# labels and expected values
tab_xtab(
efc$e16sex,
efc$e42dep,
var.labels = c("Elder's gender", "Elder's dependency"),
show.exp = TRUE
)
# print minimal cross table with labels, total col/row highlighted
tab_xtab(efc$e16sex, efc$e42dep, show.cell.prc = FALSE, emph.total = TRUE)
# User defined style sheet
tab_xtab(efc$e16sex, efc$e42dep,
CSS = list(css.table = "border: 2px solid;",
css.tdata = "border: 1px solid;",
css.horline = "border-bottom: double blue;"))
# ordinal data, use Kendall's tau
tab_xtab(efc$e42dep, efc$quol_5, statistics = "kendall")
# calculate Spearman's rho, with continuity correction
tab_xtab(
efc$e42dep,
efc$quol_5,
statistics = "spearman",
exact = FALSE,
continuity = TRUE
)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.