sjPlot (version 2.0.0)

sjt.frq: Summary of frequencies as HTML table

Description

Shows (multiple) frequency tables as HTML file, or saves them as file.

Usage

sjt.frq(data, weight.by = NULL, title.wtd.suffix = " (weighted)",
  var.labels = NULL, value.labels = NULL, sort.frq = c("none", "asc",
  "desc"), altr.row.col = FALSE, string.val = "value", string.cnt = "N",
  string.prc = "raw %", string.vprc = "valid %",
  string.cprc = "cumulative %", string.na = "missings", emph.md = FALSE,
  emph.quart = FALSE, show.summary = TRUE, show.skew = FALSE,
  show.kurtosis = FALSE, skip.zero = "auto", ignore.strings = TRUE,
  auto.group = NULL, auto.grp.strings = TRUE, max.string.dist = 3,
  digits = 2, 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),
  • each frequency table as web page content (page.content.list),
  • the complete html-output (output.complete) and
  • the html-table with inline-css for use with knitr (knitr)
for further use.

Details

How does the CSS-argument work? With the CSS-argument, the visual appearance of the tables can be modified. To get an overview of all style-sheet-classnames that are used in this function, see return value page.style for details. Arguments for this list have following syntax:
  1. the class-names with"css."-prefix as argument name and
  2. each style-definition must end with a semicolon
You can add style information to the default styles by using a + (plus-sign) as initial character for the argument attributes. Examples:
  • css.table = 'border:2px solid red;'for a solid 2-pixel table border in red.
  • css.summary = 'font-weight:bold;'for a bold fontweight in the summary row.
  • css.lasttablerow = 'border-bottom: 1px dotted blue;'for a blue dotted border of the last table row.
  • css.colnames = '+color:green'to add green color formatting to column names.
  • css.arc = 'color:blue;'for a blue text color each 2nd row.
  • css.caption = '+color:red;'to add red font-color to the default table caption style.
See further examples at http://www.strengejacke.de/sjPlot/sjtbasics{sjPlot manual: sjt-basics}.

See Also

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

Examples

Run this code
# load sample data
library(sjmisc)
data(efc)

# show frequencies of "e42dep" in RStudio Viewer Pane
# or default web browser
sjt.frq(efc$e42dep)

# plot and show frequency table of "e42dep" with labels
sjt.frq(efc$e42dep, var.labels = "Dependency",
        value.labels = c("independent", "slightly dependent",
                         "moderately dependent", "severely dependent"))

# plot frequencies of e42dep, e16sex and c172code in one HTML file
# and show table in RStudio Viewer Pane or default web browser
# Note that value.labels of multiple variables have to be
# list-objects
sjt.frq(data.frame(efc$e42dep, efc$e16sex, efc$c172code),
        var.labels = c("Dependency", "Gender", "Education"),
        value.labels = list(c("independent", "slightly dependent",
                              "moderately dependent", "severely dependent"),
                            c("male", "female"), c("low", "mid", "high")))

# auto-detection of labels
sjt.frq(data.frame(efc$e42dep, efc$e16sex, efc$c172code))

# plot larger scale including zero-counts
# indicating median and quartiles
sjt.frq(efc$neg_c_7, emph.md = TRUE, emph.quart = TRUE)

# sort frequencies
sjt.frq(efc$e42dep, sort.frq = "desc")

# User defined style sheet
sjt.frq(efc$e42dep,
        CSS = list(css.table = "border: 2px solid;",
                   css.tdata = "border: 1px solid;",
                   css.firsttablecol = "color:#003399; font-weight:bold;"))

Run the code above in your browser using DataLab