I have a 16968 row data frame (reasons for exactitude will be made clear below). I am checking to see whether a running variable (data$Ob) is actually counting every row in sequential order (first row data$Ob is 1...last row data$Ob is 16968 and for every row in between.
When I ran summary(data$Ob) it tells me that the maximum is 16970 not 16968. When I ran max(data$Ob) it says the maximum is 16968, and not the value from summary.
I ran a for-loop to check each observation, and it looks like the max() function is right and that the data$Ob variable is doing what its supposed to. But does anyone know why the summary function is off by 2? I assume rounding error (somehow?) but this data check is critical to the analysis I'm doing and if its wrong then my subsequent analysis will be bunk.
Here's the for-loop I ran but I don't think that is critical to this question.
checker <- vector(length=nrow(rd))
na.checker <- vector(length=nrow(rd))
for (i in 1:nrow(rd)){
checker[i] <- ifelse(i==rd$Ob[i], 1, 0)
na.checker[i] <- ifelse(is.na(rd$Ob[i])==TRUE,0,1)
}
sum(checker)
Thanks.