Learn R Programming

sjPlot (version 2.0.0)

sjt.xtab: Summary of contingency tables as HTML table

Description

Shows contingency tables as HTML file in browser or viewer pane, or saves them as file.

Usage

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.summary = TRUE,
  show.legend = FALSE, show.na = FALSE, 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, no.output = FALSE, remove.spaces = TRUE)

Arguments

Value

Invisibly returns
  • the web page style sheet (page.style),
  • the web page content (page.content),
  • the complete html-output (output.complete) and
  • the html-table with inline-css for use with knitr (knitr)
for further use.

Details

See 'Details' in sjt.frq.

See Also

  • http://www.strengejacke.de/sjPlot/sjt.xtab{sjPlot manual: sjt.xtab}
  • sjp.xtab

Examples

Run this code
# prepare sample data set
library(sjmisc)
data(efc)
efc.labels <- get_labels(efc)

# print simple cross table with labels
sjt.xtab(efc$e16sex, efc$e42dep)
         
# print cross table with manually set
# labels and expected values
sjt.xtab(efc$e16sex, efc$e42dep, var.labels = c("Elder's gender", 
         "Elder's dependency"), value.labels = list(efc.labels[['e16sex']], 
         efc.labels[['e42dep']]), show.exp = TRUE)

# print minimal cross table with labels, total col/row highlighted
sjt.xtab(efc$e16sex, efc$e42dep, show.cell.prc = FALSE, emph.total = TRUE)

# User defined style sheet
sjt.xtab(efc$e16sex, efc$e42dep, 
         CSS = list(css.table = "border: 2px solid;",
                    css.tdata = "border: 1px solid;",
                    css.horline = "border-bottom: double blue;"))

Run the code above in your browser using DataLab