ecohealthalliance / ohcleandat

One Health Data Cleaning and Quality Checking Package
https://ecohealthalliance.github.io/ohcleandat/
MIT License
0 stars 0 forks source link

Function to create a template for create_rules functions #21

Open collinschwantes opened 4 months ago

collinschwantes commented 4 months ago

create_rules type functions have specific requirements and specific forms

input:

create_rules_template(name = "create_rules_SOME_DATA", dir = "R")

output:

# in file R/create_rules_SOME_DATA.R

create_rules_SOME_DATA <- function(){
## each rule should be named after the column its validating
rule1 <- validator(
        some_column = !is.na(some_column)
    )

## make sure descriptions are concise and interpretable
description(rule1) <- rep("Some description",length(rule1))
.
.
.
ruleN <- validator(
        TEST_NO = field_format(TEST_NO, "\\d+" , type="regex")
)
description(ruleN) <- rep("Some description",length(ruleN))

out <- list(
    rule1 = rule1,
    .
    .
    .
    ruleN = ruleN
    )

return(out)
}