Quantcast

TRUE/FALSE

classic Classic list List threaded Threaded
3 messages Options
cm
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

TRUE/FALSE

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,
> (round(pos[o+1])==(pos[o+1]-.4) )
  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.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: TRUE/FALSE

Sarah Goslee
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 <[hidden email]> 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
>

--
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: TRUE/FALSE

Jim Lemon
In reply to this post by cm
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...