Created
September 12, 2016 10:41
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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