Learn R Programming

labelVector (version 0.1.2)

set_label: Set the label of an atomic vector

Description

Variable labels are a common construct in statistical software, giving users the ability to provide plain text descriptions for variables. These descriptions can be more informative of the variable's purpose, since they need not be restricted to the naming conventions imposed on variable names.

Usage

set_label(x, ...)

# S3 method for default set_label(x, label, ...)

# S3 method for data.frame set_label(x, ..., .dots = list())

Arguments

x

An atomic vector

...

For the default method, arguments to pass to other methods. For the data.frame method, key-pairs of the pattern variable = 'label'.

label

character(1), A character string denoting the label to assign to the variable.

.dots,

for data frames, a named list of key-pairs mapping the variable name to the label.

See Also

get_label

Examples

Run this code
# NOT RUN {
x <- 1:10
x <- set_label(x, "Integers")
x

# Set labels for variables in a data frame

mtcars2 <-
  set_label(mtcars,
            am = "Automatic / Manual",
            mpg = "Miles per Gallon",
            gear = "Number of gears")

get_label(mtcars2)

# }

Run the code above in your browser using DataLab