-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to_numeric()
with inversed factor levels
#469
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #469 +/- ##
==========================================
+ Coverage 89.09% 89.10% +0.01%
==========================================
Files 72 72
Lines 5409 5414 +5
==========================================
+ Hits 4819 4824 +5
Misses 590 590 ☔ View full report in Codecov by Sentry. |
to_numeric()
with inversed factor levels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Once you change one or two files, there's a chain reaction of lintrs you have to fix ;-) |
Behaviour is now in line with library(datawizard)
f <- c(0, 0, 1, 1, 1, 0, 1)
x1 <- factor(f, levels = c(0, 1))
x2 <- factor(f, levels = c(1, 0))
table(as.numeric(x1))
#>
#> 1 2
#> 3 4
out <- to_numeric(x1, dummy_factors = FALSE, preserve_levels = FALSE)
table(out)
#> out
#> 1 2
#> 3 4
table(as.numeric(x2))
#>
#> 1 2
#> 4 3
out <- to_numeric(x2, dummy_factors = FALSE, preserve_levels = FALSE)
table(out)
#> out
#> 1 2
#> 4 3 Created on 2023-11-27 with reprex v2.0.2 |
See also easystats/insight#835