From hb at stat.berkeley.edu  Tue Sep 23 19:46:21 2008
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Tue, 23 Sep 2008 10:46:21 -0700
Subject: [Rd] Bug in base::mean.default ? (PR#12984)
In-Reply-To: <20080923152507.231832834169@mail.pubhealth.ku.dk>
References: <20080923152507.231832834169@mail.pubhealth.ku.dk>
Message-ID: <59d7961d0809231046q7f6b5af7yf6faf290d477a438@mail.gmail.com>

Not a bug.  There is a statement in base::mean.default() before this

    if (na.rm)
        x <- x[!is.na(x)]

that removes any missing values.  Thus, it is known that there are no
missing values beyond this statement.

/Henrik

On Tue, Sep 23, 2008 at 8:25 AM,  <han at enfor.dk> wrote:
> In the body of base::mean.default the following piece of code is found:
>
>        if (trim >= 0.5)
>            return(stats::median(x, na.rm = FALSE))
>
> Should this not be
>
>         if (trim >= 0.5)
>            return(stats::median(x, na.rm = na.rm))
>
> where na.rm is supplied in the call to mean.default?
>
> If considered a bug I can imagine why it has low practical importance...
>
> Kind regards,
> Henrik
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Bug in base::mean.default ? (PR#12984)
Henrik Bengtsson