Learn R Programming

sjPlot (version 2.4.0)

view_df: View structure of labelled data frames

Description

Save (or show) content of an imported SPSS, SAS or Stata data file, or any similar labelled data.frame, as HTML table. This quick overview shows variable ID number, name, label, type and associated value labels. The result can be considered as "codeplan" of the data frame.

Usage

view_df(x, weight.by = NULL, altr.row.col = TRUE, show.id = TRUE,
  show.type = FALSE, show.values = TRUE, show.string.values = FALSE,
  show.labels = TRUE, show.frq = FALSE, show.prc = FALSE,
  show.wtd.frq = FALSE, show.wtd.prc = FALSE, show.na = FALSE,
  max.len = 15, sort.by.name = FALSE, wrap.labels = 50,
  hide.progress = FALSE, CSS = NULL, encoding = NULL, file = NULL,
  use.viewer = TRUE, no.output = FALSE, remove.spaces = TRUE)

Arguments

x

A (labelled) data frame, imported by read_spss, read_sas or read_stata function, or any similar labelled data frame (see set_label and set_labels).

weight.by

Vector of weights that will be applied to weight all cases. Must be a vector of same length as the input vector. Default is NULL, so no weights are used.

altr.row.col

Logical, if TRUE, alternating rows are highlighted with a light gray background color.

show.id

Logical, if TRUE (default), the variable ID is shown in the first column.

show.type

logical, if TRUE, the variable type is shown in a separate row respectively column.

show.values

Logical, if TRUE (default), the variable values are shown as additional column.

show.string.values

Logical, if TRUE, elements of character vectors are also shown. By default, these are omitted due to possibly overlengthy tables.

show.labels

Logical, if TRUE (default), the value labels are shown as additional column.

show.frq

Logical, if TRUE, an additional column with frequencies for each variable is shown.

show.prc

Logical, if TRUE, an additional column with percentage of frequencies for each variable is shown.

show.wtd.frq

Logical, if TRUE, an additional column with weighted frequencies for each variable is shown. Weights strem from weight.by.

show.wtd.prc

Logical, if TRUE, an additional column with weighted percentage of frequencies for each variable is shown. Weights strem from weight.by.

show.na

logical, if TRUE, NA's (missing values) are added to the output.

max.len

Numeric, indicates how many values and value labels per variable are shown. Useful for variables with many different values, where the output can be truncated.

sort.by.name

Logical, if TRUE, rows are sorted according to the variable names. By default, rows (variables) are ordered according to their order in the data frame.

wrap.labels

numeric, determines how many chars of the value, variable or axis labels are displayed in one line and when a line break is inserted.

hide.progress

logical, if TRUE, the progress bar that is displayed when creating the output is hidden. Default in FALSE, hence the bar is visible.

CSS

A list with user-defined style-sheet-definitions, according to the official CSS syntax. For more details, see this package-vignette, or 'Details' in sjt.frq.

encoding

String, indicating the charset encoding used for variable and value labels. Default is NULL, so encoding will be auto-detected depending on your platform (e.g., "UTF-8" for Unix and "Windows-1252" for Windows OS). Change encoding if specific chars are not properly displayed (e.g. German umlauts).

file

Destination file, if the output should be saved as file. If NULL (default), the output will be saved as temporary file and openend either in the IDE's viewer pane or the default web browser.

use.viewer

Logical, if TRUE, the HTML table is shown in the IDE's viewer pane. If FALSE or no viewer available, the HTML table is opened in a web browser.

no.output

Logical, if TRUE, the html-output is neither opened in a browser nor shown in the viewer pane and not even saved to file. This option is useful when the html output should be used in knitr documents. The html output can be accessed via the return value.

remove.spaces

Logical, if TRUE, leading spaces are removed from all lines in the final string that contains the html-data. Use this, if you want to remove parantheses for html-tags. The html-source may look less pretty, but it may help when exporting html-tables to office tools.

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

Examples

Run this code
# NOT RUN {
# init dataset
data(efc)

# view variables
view_df(efc)

# view variables w/o values and value labels
view_df(efc, show.values = FALSE, show.labels = FALSE)

# view variables including variable typed, orderd by name
view_df(efc, sort.by.name = TRUE, show.type = TRUE)

# User defined style sheet
view_df(efc,
        CSS = list(css.table = "border: 2px solid;",
                   css.tdata = "border: 1px solid;",
                   css.arc = "color:blue;"))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab