Created
December 5, 2016 14:16
-
-
Save aammd/85a1a3bd4ca262359bee4495dc053a32 to your computer and use it in GitHub Desktop.
are a vector of range edges, separated by _, continuous?
This file contains hidden or 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
## this function will print "TRUE" if the categories defined by the vector are | |
## continuous, e.g. c("1500_20000","20000_NA","0_1500" ) ` | |
is_continuous_categories <- function(cat_vector){ | |
cat_range <- cat_vector %>% | |
str_split("_") %>% | |
transpose %>% | |
map(unlist) %>% | |
{c(invoke(setdiff, .), invoke(setdiff, rev(.)))} | |
identical(cat_range, c("0", "NA")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment