labelValues: Manipulate labels

Description Usage Arguments Details Author(s) See Also Examples

View source: R/labelValues.R

Description

labelValues attach value labels to variables

Usage

1
2
3
4
5
6
7
labelValues(data = NULL, var, lbl, useNA = FALSE)

## Default S3 method:
labelValues(data = NULL, var, lbl, useNA = FALSE)

## S3 method for class 'list'
labelValues(data = NULL, var, lbl, useNA = FALSE)

Arguments

data

a dataframe object (Optional)

var

vectors or lists

lbl

specify a string

useNA

force to use NA as level, if any

Details

The order of the labels appearing is the same as output from tab function.

If data is specified, it returns the whole dataframe with recoded variables. Otherwise, only one vector can be used to label values.

Author(s)

Myo Minn Oo (Email: dr.myominnoo@gmail.com | Website: https://myominnoo.github.io/)

See Also

labelVars, labelData

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
str(infert)
infert.new <- labelValues(infert, case, c("no", "yes"))
table(infert.new$case)

infert.new <- labelValues(infert,
            list(case, induced),
            list(c("no", "yes"), c("none", "one", "two")))
table(infert.new$case)
table(infert.new$induced)

summary(labelValues(infert, education, c("low", "mid", "high")))
summary(labelValues(infert,
                list(education, induced),
                list(c("low", "mid", "high"),
                     c("none", "one", "two"))))

# vector
case.new <- infert$case
labelValues(NULL, case.new, c("no", "yes"))

## End(Not run)

myominnoo/mStats_beta documentation built on Feb. 29, 2020, 8:17 a.m.