[R] error message re: max(i), but code and output seen O.K.

Rolf Turner r.turner at auckland.ac.nz
Wed May 20 23:03:49 CEST 2009


On 21/05/2009, at 6:23 AM, Kirsten Miles wrote:

> I have a researcher who is consistently get the warning message:
>
> In max(i) : no non-missing arguments to max; returning -Inf
>
> Best as I can tell the code is working properly and the output is as
> expected. I would like some help in understanding why he is getting  
> this
> error message and what its implications are.  I have his code.

(a) This is not an error message, it is a warning message.

(b) The message says that, in a particular context, all of the
arguments to max() are missing.  Hence you are taking the maximum
of the empty set.  By definition this maximum is -infinity.  (This
makes good sense when you think about it carefully.)

(c) What the implications are is hard to say without knowing what the
code is actually doing.  You say that the output is as expected; this
*probably* means that the definition of the maximum of the empty set
is meshing as it should with the remainder of the calculations.

However if I were doing it, I'd track down the instance where all
of the arguments to max are missing and make sure that the code
really is doing the right thing.  You have to decide what *is*
the right thing.  What *should* happen if all of the arguments are NA?

One way to start tracking down the instance would be to set

	options(warn=2)

to change the warning to a real error, and then use traceback() to
see where the error occurred.

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}




More information about the R-help mailing list