Introduction to Writing Functions in R
Richie Cotton
Data Evangelist at DataCamp
x %>%
log() %>%
mean() %>%
exp()
calc_geometric_mean <- function(x) {
x %>%
log() %>%
mean() %>%
exp()
}
calc_geometric_mean <- function(x, na.rm = FALSE) {
x %>%
log() %>%
mean(na.rm = na.rm) %>%
exp()
}
calc_geometric_mean <- function(x, ...) {
x %>%
log() %>%
mean(...) %>%
exp()
}
Introduction to Writing Functions in R