I have some older code that I am trying to rework since funs() has been depreciated (I know, I'm way behind!). I use the output this style of summarise_if gives often, but cannot get it to work with list().
Older Code:
iris_means<-iris %>%
group_by(Species) %>%
summarise_if(is.numeric,funs(N=n(),mean,sd, se=sd(.)/sqrt(n()))) %>%
ungroup()
I tried this as I though I was getting the same error because of another package masking n(), but apparently I am doing something else wrong as I still get the error:Error in n()
:
! Must only be used inside data-masking verbs like mutate()
, filter()
, and group_by()
.
iris_means<-iris %>%
group_by(Species) %>%
dplyr::summarise_if(is.numeric,list(N=n(),mean,sd, se=sd(.)/sqrt(n()))) %>%
ungroup()
How can I update this code to make it work correctly and give the same column names as before funs() is totally gone?