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
1,404 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 24, 2020 by Niroj
• 82,840 points

Related Questions In Others

0 votes
1 answer

Android Studio: Where is the Compiler Error Output Window?

While using Android Studio 3.1, please select ...READ MORE

answered Feb 11, 2022 in Others by Rahul
• 9,680 points
3,899 views
0 votes
1 answer

web.xml is missing and <failOnMissingWebXml> is set to true

You can also use the following method: Right ...READ MORE

answered Feb 18, 2022 in Others by Aditya
• 7,680 points
1,144 views
0 votes
1 answer

Is there a way to SUMIFS with multiple criteria + true or false?

You can add this as the  last criteria: =SUMIFS(STORE!$C$6:$C$1000;STORE!$A$6:$A$1000;""&SUMMARY!$D$5&"";STORE!$D$6:$D$1000;""&SUMMARY!$C$9&"";STORE!$E$6:$E$1000;""&SUMMARY!D8&"";STORE!$AA$6:$AA$1000;TRUE) STORE!$AA$6:$AA$1000: ...READ MORE

answered Oct 1, 2022 in Others by narikkadan
• 63,600 points
1,080 views
0 votes
1 answer

MS Excel TRUE/FALSE Formula Not Returning Expected Result

The reason for this is that the 'words' ...READ MORE

answered Nov 8, 2022 in Others by gaurav
• 23,260 points
2,686 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,620 points
3,250 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,700 points
656 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 28, 2018 in Data Analytics by Sophie may
• 10,620 points
721 views
+1 vote
1 answer

R Programming: Market Basket Analysis Error

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

answered Feb 12, 2019 in Data Analytics by Sophie may
• 10,620 points
1,507 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,840 points
1,856 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP