Skip to content

Instantly share code, notes, and snippets.

@usrbinr
Created July 5, 2025 15:42
Show Gist options
  • Select an option

  • Save usrbinr/7e01e6e4bae4321c20315413e13690c6 to your computer and use it in GitHub Desktop.

Select an option

Save usrbinr/7e01e6e4bae4321c20315413e13690c6 to your computer and use it in GitHub Desktop.
replace_na() with new vs previous anonymous fucntion
## this works
cohorts::cohort_table_day(.data, id_var = customer_id, date = invoice_date) |>
dplyr::mutate(
dplyr::across(dplyr::everything(), ~tidyr::replace_na(., 0))
)
## this doesn't work
cohorts::cohort_table_day(.data, id_var = customer_id, date = invoice_date) |>
dplyr::mutate(
dplyr::across(dplyr::everything(), \(x) tidyr::replace_na(., 0))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment