tab_attrs: Tabulate a dataframe's variables' attributes

View source: R/tab_functions.R

tab_attrsR Documentation

Tabulate a dataframe's variables' attributes

Description

Tabulate a dataframe's variables' attributes

Usage

tab_attrs(df)

Arguments

df

Dataframe

Value

Dataframe with one row per variable in df, containing the following columns: "var", "varlab", "val", "vallab", "format.spss", "labels", "display_width" & "class". In contrast to tab_types() the class shows the original type as it is imported by haven. This means labelled numerics or characters belong to the class haven_labelled.

Examples

path <- system.file("examples", "iris.sav", package = "haven")
df <- haven::read_sav(path) %>%
  # add id column
  tibble::rownames_to_column("id")

df %>% tab_attrs()
# Only show variables with a variable label:
df %>% tab_attrs() %>% dplyr::filter(!sapply(varlab, is.null))

urswilke/tablab documentation built on Oct. 17, 2022, 8:19 p.m.