[R] error in Recursive

arunkumar1111 akpbond007 at gmail.com
Tue Jan 10 05:08:05 CET 2012


Hi
 
I need help in the recursive problem.  this is my code

#Generate two random Numbers
minval=20
maxval=100
cutoffValue=50

optVal<- function(cutoffValue,minval,maxval)
{
   x=runif(2)
   x=x*cutoffValue
   for( i in 1:2)
    {
      if(x[i] < 30 || x[i] >60)   # checking it falls between the range
      {
        optVal(cutoffValue,minval,maxval)
      }
   }
   return(x)
}

optVal(40,20,60)

I'm getting Error like this
*Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?*

Please help me to solve this error.  This takes infinite loop

-----
Thanks in Advance
        Arun
--
View this message in context: http://r.789695.n4.nabble.com/error-in-Recursive-tp4281052p4281052.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list