Learn R Programming

crosstable (version 0.3.2)

set_label: Set the "label" attribute of an object

Description

Set the "label" attribute of an object

Copy the label from one variable to another

Usage

set_label(x, value, object = FALSE)

copy_label_from(x, from)

Arguments

x

the variable to label

value

value of the label. If x is a list/data.frame, all the labels will be set recursively

object

if x is a list/data.frame, object=TRUE will force setting the labels of the object instead of the children

from

the variable whose label must be copied

Value

An object of the same type as x, with labels

An object of the same type as x, with the label of from

See Also

get_label(), import_labels(), remove_label()

Examples

Run this code
# NOT RUN {
library(dplyr)
mtcars %>% 
   mutate(mpg2=set_label(mpg, "Miles per gallon"),
          mpg3=mpg %>% copy_label_from(mpg2)) %>% 
   crosstable(c(mpg, mpg2, mpg3))
mtcars %>% 
   copy_label_from(mtcars2[,1:11]) %>% 
   crosstable(c(mpg, vs))
# }

Run the code above in your browser using DataLab