Learn R Programming

sjPlot (version 1.7)

sjt.frq: Show frequencies as HTML table

Description

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

Usage

sjt.frq(data, file = NULL, weightBy = NULL, variableLabels = NULL,
  valueLabels = NULL, autoGroupAt = NULL, sort.frq = NULL,
  alternateRowColors = FALSE, stringValue = "value", stringCount = "N",
  stringPerc = "raw %", stringValidPerc = "valid %",
  stringCumPerc = "cumulative %", stringMissingValue = "missings",
  highlightMedian = FALSE, highlightQuartiles = FALSE,
  skipZeroRows = "auto", showSummary = TRUE, showSkew = FALSE,
  showKurtosis = FALSE, skewString = "γ",
  kurtosisString = "ω", removeStringVectors = TRUE,
  autoGroupStrings = TRUE, maxStringDist = 3, encoding = NULL,
  CSS = NULL, useViewer = TRUE, no.output = FALSE, remove.spaces = TRUE)

Arguments

Value

Invisibly returns a structure with
  • 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.

See Also

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

Examples

Run this code
# load sample data
data(efc)

# retrieve value and variable labels
variables <- get_var_labels(efc)
values <- get_val_labels(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,
        variableLabels=variables['e42dep'],
        valueLabels=values[['e42dep']])

# plot frequencies of e42dep, e16sex and c172code in one HTML file
# and show table in RStudio Viewer Pane or default web browser
sjt.frq(as.data.frame(cbind(efc$e42dep, efc$e16sex, efc$c172code)),
        variableLabels=list(variables['e42dep'], variables['e16sex'], variables['c172code']),
        valueLabels=list(values[['e42dep']], values[['e16sex']], values[['c172code']]))

# plot larger scale including zero-counts
# indicating median and quartiles
sjt.frq(efc$neg_c_7,
        variableLabels=variables['neg_c_7'],
        valueLabels=values[['neg_c_7']],
        highlightMedian=TRUE,
        highlightQuartiles=TRUE)

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

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

# --------------------------------
# User defined style sheet
# --------------------------------
sjt.frq(efc$e42dep,
        variableLabels=variables['e42dep'],
        valueLabels=values[['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