How to update code when summarise_each() and funs() are depreciated

32 Views Asked by At

I wrote this piece of code a while ago and am now getting the below warning messages when I run it:

    group_by(ID) %>%
    summarise_each(funs(if (is.numeric(.))
      mean(., na.rm = TRUE)
      else
        first(.)))

Warning messages: 1: summarise_each_() was deprecated in dplyr 0.7.0. Please use across() instead. This warning is displayed once every 8 hours. Call lifecycle::last_lifecycle_warnings() to see where this warning was generated. 2: funs() was deprecated in dplyr 0.8.0. Please use a list of either functions or lambdas:

Simple named list: list(mean = mean, median = median)

Auto named with tibble::lst(): tibble::lst(mean, median)

Using lambdas list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))

I have tried to update the code based using across() and list() but I cannot get it to work. Any ideas of how this code should be correctly updated?

Thanks

0

There are 0 best solutions below