[R] Problem whit a piece of program

Kevin E. Thorpe kevin.thorpe at utoronto.ca
Thu Oct 13 16:48:44 CEST 2005


Arturo Coral Alamo wrote:
> Hi friends, I'm beginning in R and I have simple question.
> 
> I have this piece of my program and how you see, that's ok (whit > num<-
> 0.002)
> 
> num<-0.002 # ok, but not when I change whit num<-0... ?
> factor1<-1;
> while(1)
> {
> if (num*factor1<1)
> factor1<-factor1*10
> else
> {
> print("out ok!!");
> break;
> }
> }
> 
> [1] "out ok!!"
> 
> 
> but when I change (whit > num<-0) R show this:

Since num==0, num*factor1 is always 0 and so the loop never terminates 
and factor1 grows without bound becoming Inf.

> Error in if (num * factor1 < 1) factor1 <- factor1 * 10 else { :
> missing value where TRUE/FALSE needed
> 
> 
> I can't understand that error, can somebody help me, please
> thanks in advance
>  Jac


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: kevin.thorpe at utoronto.ca  Tel: 416.946.8081  Fax: 416.946.3297




More information about the R-help mailing list