tidyverse / modelr

Helper functions for modelling
https://modelr.tidyverse.org
GNU General Public License v3.0
401 stars 66 forks source link

typical values for NA #80

Closed dchiu911 closed 5 years ago

dchiu911 commented 5 years ago

The documentation says NA values are silently dropped. In a character variable with only NA this may lead to some unexpected downstream behaviour:

# silently dropped
modelr::typical(c("A", rep(NA_character_, 3)))
#> [1] "A"

# most frequent
modelr::typical(NA)
#> [1] NA

# length zero NULL value causes errors downstream
modelr::typical(rep(NA_character_, 3))
#> NULL
#> Warning message:
#> In max(counts) : no non-missing arguments to max; returning -Inf

If this is the intended behaviour I will modify my code accordingly.