0

I have tried trouble shooting this error I am getting and I can't seem to fix it, any help would be appreciated.

Here is the code:

wq.fn<-function(l,m,c)
{
  ro=((l)/(m*c))
  if( ro>=1) return(NA)
    r=l/m
  if(ro<1)
  {
b=r^c/(factorial(c)*(1-ro))
a=0
for(n in 0:(c-1))
{
  a=a+((r^n)/factorial(n))
}
po=1/(a+b)  
wq=(r^c/(factorial(c)*(c*m)*((1-ro)^2)))*po
return(wq)
  }}

Tried using is.na and same error occured.

  • 1
    https://stackoverflow.com/questions/7355187/error-in-if-while-condition-missing-value-where-true-false-needed?rq=2 – rawr Mar 24 '23 at 21:21
  • @rawr, I wonder why `factorial(.)` is a repeating theme today ... https://stackoverflow.com/questions/75837650/error-error-in-if-sum1-alpha-sum2-1-beta-missing-value-where-t#comment133772930_75837650 – r2evans Mar 24 '23 at 21:58
  • LukeKasianiuk, I suggest you add conditional logic (hints here https://stackoverflow.com/questions/75837650/error-error-in-if-sum1-alpha-sum2-1-beta-missing-value-where-t#comment133772040_75837650) to insert `browser()` into your function and nail "why" and "where" you're seeing that error. Also see https://adv-r.hadley.nz/debugging.html#browser for good discussions of interactive debugging. – r2evans Mar 24 '23 at 22:00

0 Answers0