Gives column names and labels

show_labels(df, ...)

Arguments

df

data frame

...

columns of interest. If none are specified then all columns will be used. Accepts:

  • unquoted column names (e.g., ID)

  • character column names (e.g., "ID")

  • numeric indices (e.g., 1:3)

  • tidyselect helpers (e.g., starts_with("A"))

  • vectors of any of the above

Value

A tibble with the names of df in the first column and the labels of df in the second column

Details

If a column has a vector of labels then the first label will be returned.

See also

Examples

id <- 1:4
age <- c(83, 29, 64, 40)
bwt <- c(71, 66, 70, 81)
attr(id, "label") <- "Subject ID"
attr(age, "label") <- "Age (years)"
attr(bwt, "label") <- "Weight (kg)"
df <- tibble::tibble(ID = id, AGE = age, BWT = bwt)
show_labels(df)
#> Error in show_labels(df): could not find function "show_labels"
show_labels(df, "AGE", BWT)
#> Error in show_labels(df, "AGE", BWT): could not find function "show_labels"
show_labels(df, 2)
#> Error in show_labels(df, 2): could not find function "show_labels"
show_labels(df, c("BWT", "ID"))
#> Error in show_labels(df, c("BWT", "ID")): could not find function "show_labels"
show_labels(df, tidyselect::starts_with("A"))
#> Error in show_labels(df, tidyselect::starts_with("A")): could not find function "show_labels"