R/checks.R

Defines functions get.state

Documented in get.state

#' Check if entry is a valid state
#' 
#' Searches list for acronym / state code.
#' @param state a \code{string} that is a valid two letter state code (e.g. Illinois is "IL").
#' @return returns state code: otherwise, it'll kill the process.
get.state = function(state){
  if(is.character(state)){
    if(!(state %in% names(ab.states))){
      stop("Not a valid state acronym.")
    }
    state = ab.states[state]
  }else if(is.numeric(state)){
    if(!(state %in% ab.states)){
      stop("Not a valid state code.")
    }
    
  }else{
    stop("Not a valid entry for state")
  }
  
  state
}
coatless/fiadb documentation built on May 13, 2019, 8:46 p.m.