[R] lm() silently drops NAs

Hadley Wickham h.wickham at gmail.com
Tue Jul 26 22:37:05 CEST 2016


> I think that's a bit too strict for me, so I wrote my own:
>
> na.warn <- function(object, ...) {
>   missing <- complete.cases(object)
>   if (any(missing)) {
>     warning("Dropping ", sum(missing), " rows with missing values",
> call. = FALSE)
>   }
>
>   na.exclude(object, ...)
> }

That should, of course, have been:

missing <- !complete.cases(object)

:-/

Hadley

-- 
http://hadley.nz



More information about the R-help mailing list