50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

varsExplore (version 0.3.0)

vars_explore: Searchable variable explorer with labelled variables

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

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.

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.

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.

Examples

Run this code
# NOT RUN {
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()
# }
# NOT RUN {
qog_summary <- vars_explore(qog, silent = FALSE, viewer = FALSE)

# }

Run the code above in your browser using DataLab