spurious warning in ave()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

spurious warning in ave()

Therneau, Terry M., Ph.D.
Consider the following simple data set and a call to ave:

 > tdata <- data.frame(f1=c(1,1,1,1,2,2,2,2), f2=c(1,2,1,2,1,1,1,1), y=1:8)
 > with(tdata, table(f1, f2))
    f2
f1  1 2
   1 2 2
   2 4 0

 > with(tdata, ave(y, f1, f2, FUN=max))

[1] 3 4 3 4 8 8 8 8
Warning message:
In FUN(X[[i]], ...) : no non-missing arguments to max; returning -Inf

There are no missing values in the result.  The fact that ave() apparently tried to find
the max for a combination it did not need is irrelvant to the user, and the warning is
counterproductive.

Terry T.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spurious warning in ave()

R devel mailing list
You can avoid the warnings and the unneeded calls to FUN by adding
drop=TRUE to the call to ave(), since all of its ... arguments are passed
to interaction (I think).

In TERR we dealt with this problem by adding drop=TRUE to ave's
argument list and we pass ... and drop=drop to interaction.  I'm not sure
drop=FALSE is ever desirable.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jun 14, 2017 at 6:02 AM, Therneau, Terry M., Ph.D. <
[hidden email]> wrote:

> Consider the following simple data set and a call to ave:
>
> > tdata <- data.frame(f1=c(1,1,1,1,2,2,2,2), f2=c(1,2,1,2,1,1,1,1), y=1:8)
> > with(tdata, table(f1, f2))
>    f2
> f1  1 2
>   1 2 2
>   2 4 0
>
> > with(tdata, ave(y, f1, f2, FUN=max))
>
> [1] 3 4 3 4 8 8 8 8
> Warning message:
> In FUN(X[[i]], ...) : no non-missing arguments to max; returning -Inf
>
> There are no missing values in the result.  The fact that ave() apparently
> tried to find the max for a combination it did not need is irrelvant to the
> user, and the warning is counterproductive.
>
> Terry T.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Loading...