Error missing value where TRUE FALSE needed

0 votes

Hi everyone

During run a special package, I encounter this error

Error in if (func.lambda(lower, X2, df, b = bb) * func.lambda(l.upper,  :
  missing value where TRUE/FALSE needed

main Code is 

RMSEAfun <- function (X2, df, N, CI)
{
  bb <- (1 - CI)/2
  lower <- 0
  l.upper <- X2
  u.upper <- max(N, X2 * 5)
  if (func.lambda(lower, X2, df, b = bb) * func.lambda(l.upper,
                                                       X2, df, b = bb) > 0) {
    l.lambda <- 0
  }
  else {
    l.lambda <- uniroot(f = func.lambda, lower = lower, upper = l.upper,
                        X2 = X2, b = bb, df = df)$root
  }
  if (func.lambda(lower, X2, df, b = CI + bb) * func.lambda(u.upper,
                                                            X2, df, b = CI + bb) > 0) {
    u.lambda <- 0
  }
  else {
    u.lambda <- uniroot(f = func.lambda, lower = lower, upper = u.upper,
                        X2 = X2, b = CI + bb, df = df)$root
  }
  return(c(sqrt(l.lambda/(N * df)), sqrt(u.lambda/(N * df))))
}

How can i save my life?

Aug 23, 2020 in Others by nimarah
• 120 points
234 views

1 answer to this question.

0 votes

Hello @ nimarah,

Your error seems to be in the line specified: 

if (func.lambda(lower, X2, df, b = bb) * func.lambda(l.upper,X2, df, b = bb) > 0) {
   ............................
  }

It appears your comparison is returning NA instead of one of TRUE/FALSE. You are probably running into something simillar to: if(NA >0) 

So to understand the fact and fix your snippet you have two option:

It is optimistic to comment out some line that throws an error and hope that the remainder of the code will work just fine.

Or,set options(error=recover) to trigger the debugger when an error is found, so you can investigate and understand the problem more easily. 

You can also check :

if (func.lambda(lower, X2, df, b = bb) * func.lambda(l.upper,X2, df, b = bb)== "Na") {
  //print true
  }

Hope it helps!!
Thank you!!

answered Aug 23, 2020 by Niroj
• 82,720 points

Related Questions In Others

0 votes
1 answer

Using unserialize in PHP throws the same error repeatedly

I googled 'Node no longer exists', and ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,240 points
548 views
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
10,322 views
0 votes
1 answer

Where is the documentation to refer for coinbase api integration of Etherium coin currency in php?

Hey there! Please refer to the following ...READ MORE

answered Jan 25, 2019 in Others by Omkar
• 69,130 points
167 views
0 votes
1 answer

Where can I find the details of installed files?

The details of recently and locally installed ...READ MORE

answered Mar 8, 2019 in Others by Nabarupa
91 views
0 votes
1 answer

R programming: Unexpected symbol error

Format your code this way: myfunction <- function() ...READ MORE

answered Dec 17, 2018 in Data Analytics by Sophie may
• 10,550 points
1,788 views
+1 vote
1 answer

R programming error

Alright, you can either use gsub to match the ...READ MORE

answered Dec 18, 2018 in Data Analytics by Tyrion anex
• 8,660 points
120 views
0 votes
1 answer

R Programming error in 'fert'

You're using a factor: fert <- factor(c(50,20,10,10,20,50)) levels(fert) #[1] ...READ MORE

answered Dec 27, 2018 in Data Analytics by Sophie may
• 10,550 points
138 views
+1 vote
1 answer

R Programming: Market Basket Analysis Error

The basket.sorted() has less than 5 rules. Refer ...READ MORE

answered Feb 11, 2019 in Data Analytics by Sophie may
• 10,550 points
634 views
0 votes
1 answer

I am trying to run following command But I end up with an error :

Hii Nishant, You are running this command inside ...READ MORE

answered Apr 6, 2020 in Others by Niroj
• 82,720 points
367 views