import_labels {crosstable} | R Documentation |
Import labels
Description
import_labels
imports labels from a data.frame (data_label
) to another one (.tbl
). Works in synergy with save_labels()
.
save_labels
saves the labels from a data.frame in a temporary variable that can be retrieve by import_labels
.
Usage
import_labels(
.tbl,
data_label,
name_from = "name",
label_from = "label",
warn_name = FALSE,
warn_label = FALSE,
verbose = deprecated()
)
save_labels(.tbl)
Arguments
.tbl |
the data.frame to be labelled |
data_label |
a data.frame from which to import labels. If missing, the function will take the labels from the last dataframe on which |
name_from |
in |
label_from |
in |
warn_name |
if TRUE, displays a warning if a variable name is not found in |
warn_label |
if TRUE, displays a warning if a label is not found in |
verbose |
deprecated |
Value
A dataframe, as .tbl
, with labels
.tbl
invisibly. Used only for its side effects.
Author(s)
Dan Chaltiel
See Also
get_label()
, set_label()
, remove_label()
, save_labels()
Examples
#import the labels from a data.frame to another
iris_label = data.frame(
name=c("Sepal.Length", "Sepal.Width",
"Petal.Length", "Petal.Width", "Species"),
label=c("Length of Sepals", "Width of Sepals",
"Length of Petals", "Width of Petals", "Specie name")
)
iris %>%
import_labels(iris_label) %>%
crosstable
#save the labels, use some dplyr label-removing function, then retrieve the labels
library(dplyr)
mtcars2 %>%
save_labels() %>%
transmute(disp=as.numeric(disp)+1) %>%
import_labels(warn_label=FALSE) %>% #
crosstable(disp)