Last chance! 50% off unlimited learning
Sale ends in
sjt.xtab(var.row, var.col, var.grp = NULL, weightBy = NULL, digits = 1,
file = NULL, variableLabels = NULL, valueLabels = NULL,
breakVariableLabelsAt = 40, breakValueLabelsAt = 20,
stringTotal = "Total", showObserved = TRUE, showCellPerc = FALSE,
showRowPerc = FALSE, showColPerc = FALSE, showExpected = FALSE,
showTotalN = 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)
page.style
),page.content
),output.complete
) andknitr
)sjt.frq
.sjp.xtab
# prepare sample data set
library(sjmisc)
data(efc)
efc.labels <- get_labels(efc)
# print simple cross table w/o 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,
variableLabels = c("Elder's gender", "Elder's dependency"),
valueLabels = list(efc.labels[['e16sex']], efc.labels[['e42dep']]),
showHorizontalLine = FALSE,
showCellPerc = FALSE,
highlightTotal = TRUE)
# -------------------------------
# auto-detection of labels
# -------------------------------
# print cross table with labels and all percentages
sjt.xtab(efc$e16sex, efc$e42dep,
showRowPerc = TRUE,
showColPerc = TRUE)
# print cross table with labels and all percentages, including
# grouping variable
sjt.xtab(efc$e16sex, efc$e42dep, efc$c161sex,
variableLabels=c("Elder's gender",
"Elder's dependency",
"Carer's gender"),
valueLabels=list(efc.labels[['e16sex']],
efc.labels[['e42dep']],
efc.labels[['c161sex']]),
showRowPerc = TRUE,
showColPerc = TRUE)
# ----------------------------------------------------------------
# User defined style sheet
# ----------------------------------------------------------------
sjt.xtab(efc$e16sex, efc$e42dep,
variableLabels = c("Elder's gender", "Elder's dependency"),
valueLabels = list(efc.labels[['e16sex']],
efc.labels[['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