vars_explore: Searchable variable explorer with labelled variables

Description Usage Arguments Details Value Examples

View source: R/tools.R

Description

Creates a summary dataframe that can be used in RStudio similar to the variable explorer in Stata, but which also includes the summary statistics. If 'viewer' is TRUE (default) the result is shown in RStudio's Viewer pane as a searchable datatable.

Usage

1
2
3
4
5
6
7
8
9
vars_explore(
  df,
  viewer = TRUE,
  digits = 2,
  font.size = "10pt",
  value.labels.width = 500,
  silent = TRUE,
  minimal = FALSE
)

Arguments

df

A data frame.

viewer

Logical. Whether to show results as a searchable datatable in RStudio's Viewer pane. Default is TRUE.

digits

Numeric. How many digits to show for the statistics in the Viewer Pane. Default is 2.

font.size

String. Font size in the Viewer Pane. Default is "10pt".

value.labels.width

Numeric. How many characters to include in the "Value labels" and "Values" columns. Default is 500.

silent

Logical. If FALSE, function will return the summary dataframe. Default is TRUE.

minimal

If TRUE only the number of observations and missing values are shown. Default is FALSE.

Details

This is useful particularly if you have a large dataset with a very large number of labelled variables with hard to remember names. Can also be used to generate a table of summary statistics.

Value

If 'silent = FALSE' the function returns the summary stats dataframe, each variable a row. This can be used for making summary tables, or viewed with the 'View()' function.

Examples

1
2
3
4
5
6
7
8
9
qog <- rio::import("http://www.qogdata.pol.gu.se/dataarchive/qog_bas_cs_jan18.dta")
vars_explore(qog, silent = FALSE, viewer = FALSE)
## Not run: 
vars_explore(qog)
vars_explore(qog, minimal = TRUE)
vars_explore(qog, silent = FALSE, viewer = FALSE) %>% View()

## End(Not run)
qog_summary <- vars_explore(qog, silent = FALSE, viewer = FALSE)

varsExplore documentation built on July 13, 2020, 9:06 a.m.