Open jenessalemon opened 7 years ago
Right, but did you print distance[i]
? What does that look like? Try print
ing that out in your loop and seeing what the value of distance[i]
looks like just before you get the error...
Crap it's NA. How do I fix this? It doesn't make sense for the whole thing to be fine but one iteration to be NA? I will just try printing at each step and see when it becomes NA...
It looks like the values go up and up until the last iteration, where they become NA. So I tried using if (distance[i-1] >= 5) and it worked...but that is probably not the best way to fix it!
Actually that didn't fix it, it is telling me that the wanderer is never falling off the cliff, even though he is well past 5 mi away.
Come online at https://appear.in/usubioprogramming
@Wolflab @willpearse The code for this problem starts on line 348. I have had this problem before. When I put a Boolean in to an if statement:
if (distance[i] >= 5){ return(i) break }
I get an error saying:
Error in if (distance[i] >= 5) { : missing value where TRUE/FALSE needed
I thought that that must mean that distance is just full of NAs. However, I printed distance and got real values. Any ideas on how to fix this?