tidyverse / haven

Read SPSS, Stata and SAS files from R
https://haven.tidyverse.org
Other
423 stars 115 forks source link

Throw a warning when two labelled vectors with conflicting labels are combined #669

Closed gorcha closed 2 years ago

gorcha commented 2 years ago

This PR adds a warning when combining two labelled vectors with conflicting labels, closing #667.

library(haven)
x <- labelled(1:2, c(Yes = 1, No = 2))
y <- labelled(1:2, c(Female = 1, Male = 2, Other = 3))
c(x, y)
#> Warning: `..1` and `..2` have conflicting value labels.
#> ℹ Labels for these values will be taken from `..1`.
#> x Values: 1, 2
#> <labelled<integer>[4]>
#> [1] 1 2 1 2
#> 
#> Labels:
#>  value label
#>      1   Yes
#>      2    No
#>      3 Other

Created on 2022-03-24 by the reprex package (v2.0.1)