Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7587133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:35:53+00:00 2026-05-30T19:35:53+00:00

This code produces an error: Error in while (diff < limit) { : missing

  • 0

This code produces an error:

Error in while (diff < limit) { : missing value where TRUE/FALSE
needed

i <- 1
j <- 1
limit <- 0.05
diff <- 0
ppm <- rep(NA,20)
while(i[1]<=nrow(list)) 
{
  while(diff < limit) ##This is where the error is occurring
  {
    if(j==0)
       ppm <- rep(NA,length(ppm))
    ppm[j] <- list$ppm[i]      
    j <- j+1
    if(j > 1)
       diff <- ppm[j]-ppm[j-1]
  }
  print(ppm)
}

Now i have found that this is usually because the condition in while is evaluating to NA and hence while cannot check for TRUE/FALSE. But in this case i really don’t see what the error is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:35:54+00:00Added an answer on May 30, 2026 at 7:35 pm

    On your first time through the while loop:

    • j is 1, ppm[1] gets set to the ith (first) element of list$ppm
    • j gets incremented to 2
    • j is now > 1, so you take the difference between ppm[2] which is still NA, since ppm was initialized to NA and ppm[2] hasn’t been touched yet and ppm[1]; the result is NA

    Now go back to the top of the while loop and compare diff (now NA) with limit (fixed at 0.05) … boom.

    i <- 1
    j <- 1
    limit <- 0.05
    diff <- 0     ## diff() is a built-in, probably avoid ...
    ppm <- rep(NA,20)
    list <- data.frame(ppm=1:10)  ## list is a built-in, probably avoid ...
    while(i[1]<=nrow(list))   ## why i[1] ??? why not just i ???
    {
      while(diff < limit) ##This is where the error is occurring
      {
        if(j==0)  ## as DWin says: never true, j is initialized to 1
           ppm <- rep(NA,length(ppm))
        ppm[j] <- list$ppm[i]      
        j <- j+1
        if(j > 1) {  ## always true if j is initialized to 1 and incremented the first time
          diff <- ppm[j]-ppm[j-1]  ## will be NA if ppm[j-1] is NA
          cat(j,ppm[j-1],ppm[j],diff,"\n")  ## debugging statement!
         }
      }
      print(ppm)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While this code produces the expected behavior of 1 when touching the screen: document.getElementById('someNodeId').addEventListener('touchmove',
How can this error be solved? The code produces an error when @count reaches
I have the following code but I get an error on this line userSpinner.setAdapter(adapter);
I am getting this error when i use a string array java.lang.NullPointerException The code
I have been battling with this code for quite a while and just don't
The given code produces a Floating point exception ,Can anyone tell me what this
I am using this code to enter update user permissions on a web app:
While migrating some code to the latest version of F#, included in VS2010 b1,
I was trying to return a set of objects. But this code gives me
This has been bugging me for a while... How can I string interpolate a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.