I would like to customize summary stats function. Result is NA with warnings.
my_summarise <- function(df, a) {
df %>%
summarise(Mean = mean("a"),
SD = sd("a"),
`CV%` = (sd("a") / mean("a")) * 100)
}
iris %>%
group_by(Species) %>%
my_summarise(a = Sepal.Length)
# A tibble: 3 x 4
Species Mean SD `CV%`
<fct> <dbl> <dbl> <dbl>
1 setosa NA NA NA
2 versicolor NA NA NA
3 virginica NA NA NA
There were 12 warnings (use warnings() to see them)