R/helper.R

Defines functions check_code_exist valid_code_format to_int

to_int <- function(chr) {
  as.integer(gsub(",", "", chr))
}

valid_code_format <- function(x) {
  all(nchar(x) == 6,
      !any(is.na(suppressWarnings(as.numeric(strsplit(
        x, ""
      )[[1]])))))
}

check_code_exist <- function(x) {
  nrow(krcodedata[krcodedata$code == x, ]) == 1
}
mrchypark/tqk documentation built on Sept. 4, 2023, 8:39 a.m.