SciencesPo (version 1.3.8)

label: Return or Assign a Variable Label

Description

Display a variable label for output, either text output at the console or graphics, such as a title on a graph.

Usage

label(x, value = NULL, data = .data)

Arguments

x
The variable for which to obtain the corresponding variable label.
value
If assigned, then the specified data frame is updated with this asssigned label.
data
Data frame that contains the variable of interest. The output of the function is assigned to this data frame.

Examples

Run this code
.data <- data.frame(AgeGroup=factor(
 1:9,
 labels= c("Younger than 16", "16-24",
           "25-34", "35-44", "45-54",
           "55-64", "65-74",
           "Older than 74", "(blank)"),
 ordered=TRUE),
 No=c(34, 2079, 2585, 1593,
      1274, 802, 291, 78, 13),
 Yes=c(18, 1970, 4035, 2328,
       1707, 924, 386, 68, 4))

dat <- label(AgeGroup, "Age group")

Run the code above in your browser using DataLab