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

Don't silently drop NA levels in strings2factors() #1291

Merged
merged 4 commits into from
May 23, 2024

Conversation

EmilHvitfeldt
Copy link
Member

@EmilHvitfeldt EmilHvitfeldt commented Mar 19, 2024

Bug first discovered in #1290.

  • add tests
  • add news

Before

library(recipes)

ex_data <- tibble(
  x = factor(c("a",NA,"c"), exclude = NULL)
)

ex_data$x
#> [1] a    <NA> c   
#> Levels: a c <NA>

rec_res <- recipe(~., data = ex_data) |>
  prep() |>
  bake(new_data = NULL)

rec_res$x
#> [1] a    <NA> c   
#> Levels: a c

After

library(recipes)

ex_data <- tibble(
  x = factor(c("a",NA,"c"), exclude = NULL)
)

ex_data$x
#> [1] a    <NA> c   
#> Levels: a c <NA>

rec_res <- recipe(~., data = ex_data) |>
  prep() |>
  bake(new_data = NULL)

rec_res$x
#> [1] a    <NA> c   
#> Levels: a c <NA>

@EmilHvitfeldt EmilHvitfeldt merged commit cc4643e into main May 23, 2024
9 checks passed
@EmilHvitfeldt EmilHvitfeldt deleted the strings2factors-na-bug branch May 23, 2024 23:11
Copy link

github-actions bot commented Jun 7, 2024

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant