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

Convert var_name column to character before replacing NAs #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DavisVaughan
Copy link
Owner

We are updating tidyr::replace_na() to utilize vctrs, and that results in slightly stricter / more correct type conversions. See tidyverse/tidyr#1219

We noticed in revdeps that this package broke. An easy way to see this is by installing the PR mentioned above and running:

library(dplyr)
library(tidytidbits)

mtcars %>% count_at(vars(gear, cyl))
#> Warning: The `add` argument of `group_by()` is deprecated as of dplyr 1.0.0.
#> Please use the `.add` argument instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
#> Error: Can't convert `replace$gear` <character> to match type of `data$gear` <double>.

The problem boils down to the fact that you are calling replace_na() on numeric columns, but your replacement is a character string ("missing"). This is no longer allowed. It seems like you wanted the end result to be a character vector anyways, so this PR preemptively changes the !!var_name column to a character before applying replace_na().

We would greatly appreciate if you could merge this PR and submit a patch release of your package to CRAN so we can send tidyr in!

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

Successfully merging this pull request may close these issues.

1 participant