set_label: Set the label of an atomic vector

Description Usage Arguments Source See Also Examples

View source: R/set_label.R

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

1
2
3
4
5
6
7
set_label(x, ...)

## Default S3 method:
set_label(x, label, ...)

## S3 method for class '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.

Source

Frank E Harrell Jr, with contributions from Charles Dupont and many others. (2017). Hmisc: Harrell Miscellaneous. R package version 4.0-3. https://CRAN.R-project.org/package=Hmisc

See Also

get_label

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)

labelVector documentation built on Oct. 8, 2021, 5:07 p.m.