R/filter_level_name.r

Defines functions filter_level_name

filter_level_name <- function(level_name, correct_varname, vars, level_names) {
  for(varname in vars) {
    if (substr(level_name, 0, nchar(varname)) == varname) {
      cleaned_level_name <- substr(level_name, nchar(varname) + 1, nchar(level_name))
      if (!(cleaned_level_name %in% level_names)) next
      if (varname != correct_varname) return(FALSE)
      return(cleaned_level_name)
    }
  }
  FALSE
}
robertzk/statsUtils documentation built on July 26, 2019, 5:39 p.m.