Description Usage Arguments Details Author(s) See Also Examples
label
assigns value labels to variables
1 |
x |
A vector |
labels |
specify a character vector that correspond to the levels |
See the following details on assigning labels on different types of vector.
Numeric or factor
The order of the labels appearing is the same as output from
tab
function.
Character For character, the order of labels have to be specified by alphabetical order.
Logical TRUE means 1 and FALSE 2 in a logical vector. Hence, levels shoud be corresponding to the numeric representation of the vector.
Myo Minn Oo (Email: dr.myominnoo@gmail.com | Website: https://myominnoo.github.io/)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | str(infert)
## Example 1: Numeric vector
table(infert$case)
case <- label(infert$case, c("No", "Yes"))
table(case)
## Example 2: factor
table(infert$education)
edu <- label(infert$education, c("low", "middle", "high"))
table(edu)
## Example 3: character
sex <- rep(c("Male", "Female", NA), c(30, 60, 10))
sex; table(sex)
sex1 <- label(sex, c('f', 'm'))
sex1; table(sex1)
label(sex, c('f', 'm', 'missing'))
## Example 4: Logical
s <- sex == "Male"
s; table(s)
s1 <- label(s, c("male", "female"))
s1; table(s1)
label(s, c('male', 'female', 'missing'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.