Skip to content

ave reports warning when nothing is wrong

1 message · Gabor Grothendieck

#
ave reports a warning here:
[1] 1 2 3
Warning message:
In FUN(X[[4L]], ...) : no non-missing arguments to min; returning Inf

In this case it can be avoided by using drop = TRUE which could only
be discovered by looking at the source code and at any rate should not
be necessary:
[1] 1 2 3

The problem is that internally ave uses interaction(...) -- in the
example above that would correspond to interaction(A, B).  This can
result in a factor with unused levels.  Replacing   interaction(...)
in the source code with
   interaction(..., drop = TRUE)
would avoid the warning message.
function (x, ..., FUN = mean)
{
    n <- length(list(...))
    if (n) {
        g <- interaction(...)
        split(x, g) <- lapply(split(x, g), FUN)
    }
    else x[] <- FUN(x)
    x
}
<environment: namespace:stats>
[1] "R version 2.12.1 Patched (2010-12-16 r53864)"

I got the same results with:
[1] "R version 2.13.0 Under development (unstable) (2011-02-11 r54330)"