Skip to content

Instantly share code, notes, and snippets.

@AndreaCirilloAC
Created September 12, 2016 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreaCirilloAC/7359fb79a87865b3652580ceb071cbfd to your computer and use it in GitHub Desktop.
Save AndreaCirilloAC/7359fb79a87865b3652580ceb071cbfd to your computer and use it in GitHub Desktop.
sample code on how to check serial number consistency through comparison of expected arithmetic series sum to actual sum
library(dplyr)
data <- data.frame(cod = c(rep("A",9),rep("B",10)),id =c(c(1,3,4,5,6,7,8,9,10),seq(1,10)))
data_complete <- filter(data,cod == "A")
min_step <- min (data_complete$id)
max_step <- max(data_complete$id)
expected_sum <- (1/2)*max(data$id)*(min_step+max_step)
actual_sum <- sum(data$id)
check <- expected_sum - actual_sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment