njtierney / naniar

Tidy data structures, summaries, and visualisations for missing data
http://naniar.njtierney.com/
Other
650 stars 54 forks source link

Using `across()` and co instead of scoped variants (`_if`, `_at`, `_all`) #262

Closed njtierney closed 1 year ago

njtierney commented 4 years ago

Consider:

library(naniar)
library(dplyr)

aq_imp_1 <- airquality %>%
  nabular() %>% 
  impute_below_all()

aq_imp_2 <- airquality %>%
  nabular() %>% 
  mutate(across(everything(),impute_below))

waldo::compare(
  aq_imp_1,
  aq_imp_2
)
#> ✓ No differences

Created on 2020-07-09 by the reprex package (v0.3.0)

This might also be related to #143, and the vignette on replace_with_na

njtierney commented 1 year ago

I think to do this right we would want to add some kind of message/ warning as is done in dplyr where we state that we suggest people use an alternative form of these functions.

But in the interim I think this requires

njtierney commented 1 year ago

Looking further this is best applied to impute_ functions, however doing this to replace_with_na scoped variants involves further changes as replace_with_na is currently written to only work with data frames. So I think in the interest of keeping the scope contained, it would be best to have a separate issue.