Extracts dataset and variable labels from a dataset.
get_labels.Rd
Arguments
- data
(
data.frame
) table to extract the labels from- fill
(
logical(1)
) ifTRUE
, the function will return variable names for columns with non-existent labels; otherwise will returnNA
for them
Examples
iris_with_labels <- iris
attr(iris_with_labels, "label") <- "Custom iris dataset with labels"
attr(iris_with_labels["Sepal.Length"], "label") <- c(`Sepal.Length` = "Sepal Length")
get_labels(iris_with_labels, fill = TRUE)
#> $dataset_label
#> [1] "Custom iris dataset with labels"
#>
#> $column_labels
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
#>
get_labels(iris_with_labels, fill = FALSE)
#> $dataset_label
#> [1] "Custom iris dataset with labels"
#>
#> $column_labels
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> NA NA NA NA NA
#>