lundi 8 janvier 2018

Error: missing value where TRUE/FALSE needed in R

An example of my data frame is this:

EntryTime             FixTime1            FixTime2             FixTime3
2017-12-29 00:00:00  2017-12-29 00:00:52  2017-12-29 00:01:36  2017-12-29 00:01:59

I am running the following if statement:

    if(abs(as.numeric(difftime(waypointtime,
                           entrytime,units="mins"))) <= 5) {
  EorX  <- "E" #Entry
} 

where:

for (i in 1:nrow(df){
for (j in 1:ncol(df){
    waypointtime <- df[i,1]
    entrytime <- df[i,j+1]
}
}

I keep getting the following error:

Error in if (abs(as.numeric(difftime(waypointtime, entrytime, units = "mins"))) <=  : 
missing value where TRUE/FALSE needed

Why does this error keep on occurring and how do I get rid of it?

Thanks!

Aucun commentaire:

Enregistrer un commentaire