You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
coerceAs may be doing factor coercion incorrectly #6140
test(10.16, coerceAs(1:2, factor(c("x","y"))), factor(c("x","y")), output="integer[integer] into integer[factor]")
When run in a locale where y sorts before x we get:
> x = coerceAs(1:2, factor(c("x", "y")))
First 2 of 2 (type 'integer'):
[1] y x
Levels: y x
> y = factor(c("x", "y"))
First 2 of 2 (type 'integer'):
[1] x y
Levels: y x
2 string mismatches
I am not sure the intended behavior in this case, but that output does look potentially off to me. We can fix the test if the behavior is intentional, want to check with Jan first.
Activity
jangorecki commentedon May 19, 2024
Locale was never considered when implementing this or adding this tests so it is not by design
MichaelChirico commentedon May 19, 2024
OK, so is it an error or intended?
I lean towards "data.table always uses C locale to sort, including for generating factor levels automatically" as being the correct behavior, WDYT?
jangorecki commentedon May 20, 2024
yes, agree