[R] Help with debugging

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Apr 23 00:20:17 CEST 2004


"Phillip Good" <pigood at verizon.net> 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

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list