Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

apply_labels

Set variable labels/value labels on variables in the data.frame


Description

apply_labels tries automatically detect what is variable label and what are value labels. .apply_labels is version for working with default dataset. See also var_lab and val_lab.

Usage

apply_labels(data, ...)

.apply_labels(...)

Arguments

data

data.frame/list

...

named arguments. Name of argument is a variable name in data. Argument values are variable or value labels. Unnamed characters of length 1 are considered as variable labels and named vectors are considered as value labels.

Value

data with applied labels

Examples

data(mtcars)
mtcars = apply_labels(mtcars,
                      vs = "Engine",
                      vs = num_lab("
                             0 V-engine 
                             1 Straight engine
                             "),
                      am = "Transmission",
                      am = num_lab("
                             0 Automatic 
                             1 Manual
                             ")
)

# 'table' from base R
table(mtcars$vs, mtcars$am)

# more sofisticated crosstable
calculate(mtcars, cro(vs, am))

expss

Tables, Labels and Some Useful Functions from Spreadsheets and 'SPSS' Statistics

v0.10.7
GPL (>= 2)
Authors
Gregory Demin [aut, cre], Sebastian Jeworutzki [ctb] (<https://orcid.org/0000-0002-2671-5253>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.