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
531 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,720 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 in Others by Rahul
• 8,980 points
149 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 in Others by Aditya
• 7,280 points
52 views
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
806 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
12,081 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,590 points
2,230 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,690 points
185 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,590 points
216 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,590 points
884 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
761 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP