label: Attach labels to data and variables

View source: R/label.R

labelR Documentation

Attach labels to data and variables

Description

[Stable]

This function manipulates labels. It supports different classes of objects, including default objects, data frames, and other types.

Usage

label(x, label = NULL)

Arguments

x

The object to which the label will be added or modified.

label

A character string specifying the label to be assigned to the variable.

Details

When used with dplyr's ⁠[mutate]⁠ function, this function allows for easy labeling of variables within a data frame.

If used with a data frame, the function labels the dataset itself, and the label can be checked using the ⁠[codebook]⁠ function.

Value

The modified object with the updated label.

Examples


library(dplyr)

iris |>
	 mutate(Species = label(Species, 'Species of iris flower')) |>
	 codebook()

iris |>
	 label("Iris dataset") |>
	 codebook()


myominnoo/mStats documentation built on Nov. 29, 2023, 2:36 a.m.