varlist: Variable List, Stata-style

View source: R/datahandling.R

varlistR Documentation

Variable List, Stata-style

Description

This function prints an inventory of a dataset, similar to Stata's varlist function.

Usage

varlist(data)

Arguments

data

Input data frame (tibble)

Value

Tibble with the following columns:

  • name Variable name

  • n Number of non-missing observations

  • class Variable class

  • label Variable label

Examples

# Load mtcars dataset,
# label it, and create missing values
data(mtcars)
df <- mtcars %>%
  labelled::set_variable_labels(mpg = "Miles per Gallon",
                                gear = "Number of Gears") %>%
  dplyr::mutate(qsec = dplyr::if_else(am == 1,
                                      true = NA_real_,
                                      false = qsec))

# Show varlist. Note missing values in "qsec".
varlist(df)

stopsack/khsmisc documentation built on Sept. 22, 2023, 12:26 p.m.