Learn R Programming

mStats (version 3.2.2)

labelVar: Add or replace labels of variables and dataset

Description

labelVar labels variables.

labelData labels Dataset.

Usage

labelVar(data, var, lbl = NULL)

labelData(data, lbl = NULL)

Arguments

data

dataset

var

one variable or variables

lbl

to specify labels. If not specified, label is removed

Details

Labels are useful to provide more detailed information about variables or dataset. Many functions in mStats package extract label information and display them as footnote.

Label single or multiple variables

Single or multiple variables can be labelled.

Example: single variable

labelVar(data, var, lbl)

Example: multiple variable

labelVar(data,
      c(var1, var2, var3),
      c(lbl1, lbl2, lbl3))

Label Dataset

Dataset can also be labelled and displayed in codebook.

labelData(data, lbl)

Examples

Run this code
# NOT RUN {
## use infert data
data(infert)

## label education
infert.new <- labelVar(infert, education, "patient's education")
codebook(infert.new)

## label multiple variables
infert.new <- labelVar(infert, c(education, age, case),
                       c("patient's education", "age in years", "case status"))
codebook(infert.new)


## label dataset
infert.new <- labelData(infert.new,
                        "Infertility after Spontaneous and Induced Abortion")
codebook(infert.new)

# }

Run the code above in your browser using DataLab