-
-
Save giacecco/c10aa1a290673e3c5614 to your computer and use it in GitHub Desktop.
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
# a few useful functions... | |
is.even <- function(x) sum(x %% 2 == 0) == length(x) | |
is.odd <- function(x) sum(x %% 2 != 0) == length(x) | |
# and finally, the calculation | |
can_be_inferred <- sum(apply(lrpp_streets_for_inference, 1, function (row) { | |
aons <- lrpp_addresses_with_numeric_aon[(lrpp_addresses_with_numeric_aon$street == row[1]) & (lrpp_addresses_with_numeric_aon$pcd == row[2]), "aon"] | |
# if all numbers I know are odd or even, I can only infer the missing odd and even numbers, | |
# otherwise I can infer all | |
# TODO: crazy below: why row[3] and row[4] are not numeric any longer? | |
inferred <- setdiff(seq(from = as.numeric(row[3]), to = as.numeric(row[4]), by = ifelse(is.even(aons) | is.odd(aons), 2, 1)), aons) | |
return(length(inferred)) | |
})) |
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
> can_be_inferred | |
[1] 190285 | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment