Reverse a numeric variable while maintaining variable and value labels if available. Also adds an attribute describing the transformation the original variable underwent. Please check the vignette to have a better understanding of exactly what this function does.
Examples
library(dplyr)
test_data %>%
# reverse the variable accept_isr
mutate(accept_isr_rev = num_rev(accept_isr)) %>%
select(starts_with("accept"))
#> # A tibble: 250 × 3
#> accept_hamas accept_isr accept_isr_rev
#> <dbl+lbl> <dbl+lbl> <dbl+lbl>
#> 1 3 [Somewhat unacceptable] 3 [Somewhat unacceptable] 2 [Somewhat unacceptable]
#> 2 3 [Somewhat unacceptable] 3 [Somewhat unacceptable] 2 [Somewhat unacceptable]
#> 3 4 [Totally unacceptable] 3 [Somewhat unacceptable] 2 [Somewhat unacceptable]
#> 4 4 [Totally unacceptable] 1 [Totally acceptable] 4 [Totally acceptable]
#> 5 4 [Totally unacceptable] 2 [Somewhat acceptable] 3 [Somewhat acceptable]
#> 6 3 [Somewhat unacceptable] 1 [Totally acceptable] 4 [Totally acceptable]
#> 7 3 [Somewhat unacceptable] 2 [Somewhat acceptable] 3 [Somewhat acceptable]
#> 8 3 [Somewhat unacceptable] 3 [Somewhat unacceptable] 2 [Somewhat unacceptable]
#> 9 4 [Totally unacceptable] 2 [Somewhat acceptable] 3 [Somewhat acceptable]
#> 10 4 [Totally unacceptable] 3 [Somewhat unacceptable] 2 [Somewhat unacceptable]
#> # ℹ 240 more rows