An optimized median function that uses C++ code to quickly calculate the median of a numeric vector after removing NA values.
library(fastmedian)
med(1:4)
#> [1] 2.5
med(c(1:3, 100, 1000))
#> [1] 3
med(c(NA_real_, 1:3, 100, NA_real_, 1000, NA_real_))
#> [1] 3