ComeçarComece de graça

Passing arguments with ...

Rather than explicitly giving calc_harmonic_mean() and na.rm argument, you can use ... to simply "pass other arguments" to mean().

The dplyr package is loaded.

Este exercício faz parte do curso

Introduction to Writing Functions in R

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Swap na.rm arg for ... in signature and body
calc_harmonic_mean <- function(x, na.rm = FALSE) {
  x %>%
    get_reciprocal() %>%
    mean(na.rm = na.rm) %>%
    get_reciprocal()
}
Editar e executar o código