Check textdata

namelist

namelist_check <- 
    read_vc(namelist_path, root)

Are all codes unique per language?

namelist_check %>% 
    count(code, lang) %>% 
    filter(n > 1) %>% 
    nrow == 0

No lines without names or shortname?

namelist_check %>% 
    filter(is.na(name), is.na(shortname)) %>% 
    nrow == 0

All lines have a value for code and lang?

namelist_check %>% 
    filter(is.na(code) | is.na(lang)) %>% 
    nrow == 0

Language statistics:

namelist_check %>% 
    mutate(name = !is.na(name),
           shortname = !is.na(shortname)) %>% 
    group_by(lang) %>% 
    summarize(name = sum(name),
              shortname = sum(shortname))

types

types_check <- read_vc(types_path, root)

Are all codes unique?

types_check %>% 
    count(type) %>% 
    filter(n > 1) %>% 
    nrow == 0

Are all main types correct?

types_check %>% 
    mutate(type = as.character(type),
           main_type_2 = ifelse(str_detect(type, "_|\\+"),
                                str_sub(type, 
                                        end = str_locate(type, "_|\\+") - 1),
                                type)
    ) %>% 
    filter(main_type != main_type_2) %>% 
    nrow == 0

Which are the frequencies of different combinations of hydrological class, groundwater and flood dependency?

types_check %>% 
    count(hydr_class, groundw_dep, flood_dep)

Inspecting the types data source, sorted according to the above three variables:

types_check %>% 
    arrange(hydr_class, groundw_dep, flood_dep)

env_pressures

ep_check <- read_vc(ep_path, root)

Are all codes unique?

ep_check %>% 
    count(ep_code) %>% 
    filter(n > 1) %>% 
    nrow == 0

Do ep_classes coincide between ep_code and ep_class?

ep_check %>% 
    mutate(ep_class_c = str_c("ep_class_",
                        str_match(ep_code, "ep_(..).*")[,2]
                        ),
           ep_class = as.character(ep_class)
    ) %>% 
    (function(df) {
        all.equal(df$ep_class_c, df$ep_class)
    })

Do ep_classes coincide between ep_code and explanation?

ep_check %>% 
    mutate(ep_class_c1 = str_match(ep_code, "ep_(..).*")[,2],
           ep_class_c2 = str_match(explanation, "ep_(..).*")[,2],
    ) %>% 
    (function(df) {
        all.equal(df$ep_class_c1, df$ep_class_c2)
    })


inbo/n2khab documentation built on Jan. 15, 2025, 9:36 a.m.