Skip to content

TRUE/FALSE

3 messages · cm, Sarah Goslee, Jim Lemon

cm
#
Any reason I'd get an error like this? 

Error in if (round(pos[o + 1]) == (pos[o + 1] - 0.4)) { : 
  missing value where TRUE/FALSE needed

but when i do it individually, out of the for loop,
65 
TRUE 


--
View this message in context: http://r.789695.n4.nabble.com/TRUE-FALSE-tp4636748.html
Sent from the R help mailing list archive at Nabble.com.
#
What's pos?
What's o?
What is your loop looping over?
Where's your reproducible example provided using dput()?

And more generally, have you read R FAQ 7.31 and the posting guide?

Most likely either o is wrong, or there are NA values in pos, but we
have no way to diagnose that.

Sarah
On Tue, Jul 17, 2012 at 9:55 AM, cm <bunnylover23 at optonline.net> wrote:

  
    
#
On 07/17/2012 11:55 PM, cm wrote:
Elementary, my dear cm. pos is a vector of length n. From your 
description of the problem, I suspect that you are trying to run a loop 
that looks something like this:

for(o in 1:n)) {
  if(round(pos[o+1]) == (pos[o+1]-0.4))
   print(o)
}

The error occurs on the nth loop. The additional clue that you have 
unwittingly provided in the form of the number 65 that shouldn't be 
there brings me to the conclusion that n=65.

Jim