reverse_labelled_values: Reverse labelled values reverse the underlying values for a...

Description Usage Arguments Value Examples

View source: R/correct_attributes.R View source: R/reverse_labelled_values.R

Description

Reverse labelled values reverse the underlying values for a numeric haven::labelled() vector while keeping the labels correct

Reverse labelled values reverse the underlying values for a numeric haven::labelled() vector while keeping the labels correct

Usage

1
2
3

Arguments

x

a labelled vector

Value

return the labelled vector with the underlying values having been reversed

return the labelled vector with the underlying values having been reversed

Examples

1
2
3
4
5
6
x <- haven::labelled(rep(1:3, each = 3), c(Bad = 1, Good = 5))
x
reverse_labelled_values(x)
x <- haven::labelled(rep(1:3, each = 3), c(Bad = 1, Good = 5))
x
reverse_labelled_values(x)

Example output

<labelled<integer>[9]>
[1] 1 1 1 2 2 2 3 3 3

Labels:
 value label
     1   Bad
     5  Good
<labelled<integer>[9]>
[1] 5 5 5 4 4 4 3 3 3

Labels:
 value label
     5   Bad
     1  Good
<labelled<integer>[9]>
[1] 1 1 1 2 2 2 3 3 3

Labels:
 value label
     1   Bad
     5  Good
<labelled<integer>[9]>
[1] 5 5 5 4 4 4 3 3 3

Labels:
 value label
     5   Bad
     1  Good

codebook documentation built on July 1, 2020, 10:28 p.m.