safe_median() works stats::median() but warns if some elements of ... are never used.

safe_median(x, ...)

# S3 method for numeric
safe_median(x, ..., na.rm = TRUE)

Arguments

x

Numeric vector

...

Additional arguments passed on to methods.

na.rm

For numeric method, should missing values be removed?

Examples

x <- c(1:10, NA) safe_median(x, na.rm = TRUE)
#> [1] 5.5
median(x, na.rm = TRUE)
#> [1] 5.5
try(median(x, na.mr = TRUE))
#> [1] NA
try(safe_median(x, na.mr = TRUE))
#> Error : 1 components of `...` were not used. #> #> We detected these problematic arguments: #> * `na.mr` #> #> Did you misspecify an argument?
try(median(1, 2, 3))
#> [1] 1
try(safe_median(1, 2, 3))
#> Error : 2 components of `...` were not used. #> #> We detected these problematic arguments: #> * `..1` #> * `..2` #> #> Did you misspecify an argument?