across() in functions: setup

summarize_datatypes <- function(df) {
  df |> summarize(
    across(
      where(is.numeric), 
      list(mean = \(x) mean(x, na.rm = TRUE))
    ),
    across(
      where(is.factor) | where(is.character), 
      list(n_distinct = n_distinct)
    )
  ) |> 
    glimpse()
}