DescTools (version 0.99.11)

Label: Label Attribute of an Object

Description

Set and retrieve the label attribute of x. This can be helpful for documenting the specific meaning of a variable.

Usage

Label(x, default = NULL, ...)

## S3 method for class 'default':
Label(x, ...)

## S3 method for class 'data.frame':
Label(x, ...)

Label(x, ...) <- value

## S3 method for class 'default':
Label(x, ...) <- value

## S3 method for class 'data.frame':
Label(x, self = TRUE, ...) <- value

Arguments

x
any object
default
any default
value
any object
self
any object
...
the dots are passed to the specific function.

Value

  • Label returns the label attribute of x, if any; otherwise, NULL.

Details

The label should consist of a single text (length of 1). The text may contain any line feeds. It can be deleted by setting the label to NULL.

See Also

A more elaborated version can be found in package Hmisc label().

Examples

Run this code
# add a descriptive label to a variable
Label(d.diamonds$colour) <- "The rating scale applied to diamonds ranges from colorless
to yellow, as any other color is extremely rare."

# technically just appending the text as attribute to the variable
attributes(d.diamonds$colour)

# label is supported while describing data
Desc(d.diamonds$colour)

# The label can be deleted by setting it to NULL
Label(d.diamonds$colour) <- NULL

Run the code above in your browser using DataCamp Workspace