0

Could I please get some assistance on re-writing the code below? Every time I run it, I receive the message below.

funs() was deprecated in dplyr 0.8.0.

CODE:

bind_rows(summarise_all(., funs(if(is.numeric(.)) sum(.) else ""))) %>%
        na_if(., 0) %>% 

I tried using summarize () and list() but no luck.

UseR10085
  • 7,120
  • 3
  • 24
  • 54
AVA
  • 3
  • 2
  • 1
    Does this answer your question? [How to change the now deprecated dplyr::funs() which includes an ifelse argument?](https://stackoverflow.com/questions/54833694/how-to-change-the-now-deprecated-dplyrfuns-which-includes-an-ifelse-argument) – Stuart Jun 21 '23 at 14:34
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Jun 21 '23 at 14:36

1 Answers1

0
#what you have been doing
summarise_all(
  head(iris),
  funs(if (is.numeric(.)) {
    sum(.)
  } else {
    ""
  })
)

#what you could do instead 
summarise_all(
  head(iris),
  ~(if (is.numeric(.)) {
    sum(.)
  } else {
    ""
  })
)

# further alternative
summarise(head(iris),
          across(where(is.numeric),sum),
          across(where(\(.)!is.numeric(.)),\(.){""}))

Nir Graham
  • 2,567
  • 2
  • 6
  • 10