Skip to content
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

Range training on factor with NAs #383

Closed
teunbrand opened this issue Mar 28, 2023 · 0 comments
Closed

Range training on factor with NAs #383

teunbrand opened this issue Mar 28, 2023 · 0 comments

Comments

@teunbrand
Copy link
Contributor

This issue is a port of tidyverse/ggplot2#5224.

The following behaviour is unexpected, where the order of items in the range is rearranged.

library(scales)

f <- factor(c("A", "B", "C", NA), levels = c("C", "B", "A"))
range <- DiscreteRange$new()

range$train(na.omit(f))
# This is fine
range$range
#> [1] "C" "B" "A"

range$train(f)
# This is unexpected
range$range
#> [1] "A" "B" "C"

If we flip the order in which the range is trained, everything seems to work as expected:

range$reset()
range$train(f)
range$range
#> [1] "C" "B" "A" NA

range$train(na.omit(f))
range$range
#> [1] "C" "B" "A" NA

Created on 2023-03-28 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant