moodymudskipper / safejoin

Wrappers around dplyr functions to join safely using various checks
GNU General Public License v3.0
42 stars 7 forks source link

dplyr has changed the behavior of na_matches #40

Closed karldw closed 4 years ago

karldw commented 4 years ago

Thanks for the useful package! I noticed that the na_matches configuration can be a little funny. By default, dplyr doesn't set it anymore, and if it's set, dplyr raises a warning.

Here's an example:

library(safejoin)

x <- safe_left_join(mtcars, mtcars, check="")
#> Error: `na_matches` must be a character vector.

library(dplyr, quietly = TRUE, warn.conflicts = FALSE)
x <- safe_left_join(mtcars, mtcars, check="")
#> Error: `na_matches` must be a character vector.

pkgconfig::set_config("dplyr::na_matches" = "na")

x <- safe_left_join(mtcars, mtcars, check="")
#> Warning: `dplyr::na_matches` pkgconfig options is now ignored.
#> * Please set `na_matches` directly.

Here's the relevant dplyr code: https://github.com/tidyverse/dplyr/blob/0bea3e80a876cceb9e179ef3a64d94103c350c41/R/join.r#L390

moodymudskipper commented 4 years ago

Thanks a lot for reporting, this is inconvenient indeed! I'll fix this asap

karldw commented 4 years ago

Would it help if I submitted a PR? The fix I'm imagining is set the na_matches default to c("na", "never") and add a na_matches <- match.arg(na_matches) call in the safe_join function.

moodymudskipper commented 4 years ago

Thanks Karl, it was just that indeed, with the equivalent update in eat, it should work now!

karldw commented 4 years ago

That works perfectly, thanks!