[R] can't find the error in if function... maybe i'm blind?
Jim Holtman
jholtman at gmail.com
Sat Oct 20 13:39:20 CEST 2012
Learn how to debug your programs. Start with
options(error = recover)
this will give you control at the point of the error so you can examine values. Most likely one of the variables in the 'if' expression is an NA.
Sent from my iPad
On Oct 20, 2012, at 6:27, Janosch <Janosch1985 at web.de> wrote:
> Hi everybody,
>
> the following alway gives me the error
> "Fehler in if (File$X.Frame.Number[a] + 1 == File$X.Frame.Number[a + 1])
> (File$FishNr[a] <- File$FishNr[a - : Fehlender Wert, wo TRUE/FALSE nötig
> ist". Maybe its stupid, but i'm not getting why... Maybe someone can help
> me. Thanks a lot!
>
> for (i in unique(BigFile$TrackAll))
> { File <- subset(BigFile,BigFile$TrackAll == i)
> File$FishNr [1] <- 1
> for ( a in File$X.Frame.Number)
> {if(File$X.Frame.Number[a]+1== File$X.Frame.Number[a+1])
> (File$FishNr [a] <- File$FishNr[a-1])
> else(if (File$X.Frame.Number[a]+1 !=
> File$X.Frame.Number[a+1])
> (File$FishNr [a] <- File$FishNr[a-1]+1 ))
> }
> }
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/can-t-find-the-error-in-if-function-maybe-i-m-blind-tp4646839.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.
More information about the R-help
mailing list