[R] TRUE/FALSE

Jim Lemon jim at bitwrit.com.au
Wed Jul 18 11:06:59 CEST 2012


On 07/17/2012 11:55 PM, cm wrote:
> 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,
>> (round(pos[o+1])==(pos[o+1]-.4) )
>    65
> TRUE
>
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



More information about the R-help mailing list