get_var_info: Get info about variables in a data frame

View source: R/get-var-info.R

get_var_infoR Documentation

Get info about variables in a data frame

Description

Mostly a helper function for other tidy_table_one functions. The function takes a data frame or tibble and returns a descriptive tibble with the variable names, class, binary type (categorical or continuous), and the factor levels.

Usage

get_var_info(data, .vars = NULL)

Arguments

data

A data.frame or tbl_df

.vars

A character string of variable/column names. If empty, all columns are used

Value

A tbl_df with colums for

var

name of the variable/column

level

factor level if applicable, character levels too

class

variable class

var_type

variable type: categorical or continuous

Examples

library(dplyr)
library(ggplot2)
lapply(diamonds, class)
get_var_info(data = diamonds,
             .vars = c("carat",
                       "cut",
                       "color",
                       "clarity",
                       "depth",
                       "table",
                       "price")) %>%
  print(n = Inf)


get_var_info(data = pbc_mayo)

get_var_info(data = pbc_mayo,
             .vars = c("status", "sex", "stage", "age"))

emilelatour/tidytableone documentation built on Jan. 6, 2025, 9:20 a.m.