| copy_labels {sjlabelled} | R Documentation |
Subsetting-functions usually drop value and variable labels from
subsetted data frames (if the original data frame has value and variable
label attributes). This function copies these value and variable
labels back to subsetted data frames that have been subsetted, for instance,
with subset.
copy_labels(df_new, df_origin = NULL)
df_new |
The new, subsetted data frame. |
df_origin |
The original data frame where the subset ( |
Returns df_new with either removed value and variable label attributes
(if df_origin = NULL) or with copied value and variable label
attributes (if df_origin was the original subsetted data frame).
In case df_origin = NULL, all possible label attributes
from df_new are removed.
data(efc) efc.sub <- subset(efc, subset = e16sex == 1, select = c(4:8)) str(efc.sub) efc.sub <- copy_labels(efc.sub, efc) str(efc.sub) efc.sub <- copy_labels(efc.sub) str(efc.sub)