Learn R Programming

sjPlot (version 1.9.4)

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, weightBy = NULL, digits = 1, file = NULL,
  variableLabels = NULL, valueLabels = NULL, title = NULL,
  breakVariableLabelsAt = 40, breakValueLabelsAt = 20,
  stringTotal = "Total", showObserved = TRUE, showCellPerc = FALSE,
  showRowPerc = FALSE, showColPerc = FALSE, showExpected = FALSE,
  showHorizontalLine = FALSE, showSummary = TRUE, showLegend = FALSE,
  showNA = FALSE, labelNA = "NA", tdcol.n = "black",
  tdcol.expected = "#339999", tdcol.cell = "#993333",
  tdcol.row = "#333399", tdcol.col = "#339933", highlightTotal = FALSE,
  highlightColor = "#f8f8f8", percSign = " %", hundret = "100.0",
  encoding = NULL, CSS = NULL, useViewer = 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, 
         variableLabels = c("Elder's gender", 
                            "Elder's dependency"),
         valueLabels = list(efc.labels[['e16sex']], 
                            efc.labels[['e42dep']]),
         showExpected = TRUE)

# print minimal cross table with labels, total col/row highlighted
sjt.xtab(efc$e16sex, efc$e42dep, 
         showHorizontalLine = FALSE,
         showCellPerc = FALSE,
         highlightTotal = 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