Quantcast

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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Kirsten Miles
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.

Sincerely,
Kirsten Miles
Support Specialist
Research Computing Lab
Charles L. Brown Science and Engineering Library

[hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Sundar Dorai-Raj-2
This error is thrown if the argument to max is either NULL or length zero:

[~] Rscript -e "max(NULL)"
[1] -Inf
Warning message:
In max(NULL) : no non-missing arguments to max; returning -Inf
[~] Rscript -e "max(numeric(0))"
[1] -Inf
Warning message:
In max(numeric(0)) : no non-missing arguments to max; returning -Inf

HTH,

--sundar

On Wed, May 20, 2009 at 11:23 AM, Kirsten Miles <[hidden email]> 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.
>
> Sincerely,
> Kirsten Miles
> Support Specialist
> Research Computing Lab
> Charles L. Brown Science and Engineering Library
>
> [hidden email]
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Rolf Turner
In reply to this post by Kirsten Miles

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}}

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

David Scott-6
In reply to this post by Kirsten Miles
On Wed, 20 May 2009, 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
>

You get this message when trying to take the maximum of a vector with no
elements. I am guessing he is looping through and in some cases getting an
empty vector.

> x <- numeric(0)
> max(x)
[1] -Inf
Warning message:
In max(x) : no non-missing arguments to max; returning -Inf


David Scott




> 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.
>
> Sincerely,
> Kirsten Miles
> Support Specialist
> Research Computing Lab
> Charles L. Brown Science and Engineering Library
>
> [hidden email]
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

_________________________________________________________________
David Scott Department of Statistics
  The University of Auckland, PB 92019
  Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email: [hidden email],  Fax: +64 9 373 7018

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...