On 23 Apr 2004, Peter Dalgaard wrote:

> "Phillip Good" <[EMAIL PROTECTED]> writes:
> 
> > Once the IF triggers in the following program, it just won't turn off:
> >
> 
> >  statp=F1(size,pdata,gmean,samps)
> >  if (stat0 <= statp ){
> 
> There are 2 bugs here: One in your code and one in R.
> 
> F1 returns a list, so the logical thing to do would be to use
> 
>   stat0$stat <= statp$stat
> 
> The bug in R is that it appears to be random what happens if you do
> compare lists:
> 
> > replicate(50,list(1) <= list(2))
>  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
> [13] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
> [25] FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> [49] FALSE FALSE

Yes.  relop.c has

    /* FIXME (?): S does
    if (!isVectorAtomic(x) || !isVectorAtomic(y)) { */
    if (!isVector(x) || !isVector(y)) {
        if (isNull(x) || isNull(y)) {
            UNPROTECT(2);
            return allocVector(LGLSXP,0);
        }
        errorcall(call,
                  "comparison (%d) is possible only for atomic types",
                  PRIMVAL(op));
    }

    /* ELSE :  x and y are both atomic */

but that the latter is not true, and integer_relop gets called (with 
nonsense results).  The FIXME is long overdue ....

Not that the (4) in

> list(1) <= list(2)
Error in list(1) <= list(2) : comparison (4) is possible only for atomic 
types

is very revealing.


-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to