Re: [R] lm() silently drops NAs

2016-07-30 Thread Martin Maechler
> peter dalgaard > on Tue, 26 Jul 2016 23:30:31 +0200 writes: >> On 26 Jul 2016, at 22:26 , Hadley Wickham >> wrote: >> >> On Tue, Jul 26, 2016 at 3:24 AM, Martin Maechler >> wrote: >>>

Re: [R] lm() silently drops NAs

2016-07-26 Thread Andrew Robinson
Agh. I've argued elsewhere that the default behaviour should be to fail, and the user should take the responsibility to explicitly handle the missing values, even if that simply be by changing the argument. Probably Peter and I have different experiences with the completeness of datasets, but

Re: [R] lm() silently drops NAs

2016-07-26 Thread peter dalgaard
> On 26 Jul 2016, at 22:26 , Hadley Wickham wrote: > > On Tue, Jul 26, 2016 at 3:24 AM, Martin Maechler > wrote: >> ... > To me, this would be the most sensible default behaviour, but I > realise it's too late to change without breaking many

Re: [R] lm() silently drops NAs

2016-07-26 Thread Hadley Wickham
> 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

Re: [R] lm() silently drops NAs

2016-07-26 Thread Hadley Wickham
On Tue, Jul 26, 2016 at 3:24 AM, Martin Maechler wrote: > I have been asked (in private) Martin was very polite to not share my name, but it was me :) > > Hi Martin, > > y <- c(1, 2, 3, NA, 4) > x <- c(1, 2, 2, 1, 1) > > t.test(y ~ x) > lm(y ~ x)

Re: [R] lm() silently drops NAs

2016-07-26 Thread Martin Maechler
I have been asked (in private) > Hi Martin, y <- c(1, 2, 3, NA, 4) x <- c(1, 2, 2, 1, 1) t.test(y ~ x) lm(y ~ x) > Normally, most R functions follow the principle that > "missings should never silently go missing". Do you have > any background on why these