R/existsBackgroundVariables.R

Defines functions .existsBackgroundVariables

.existsBackgroundVariables <- function(dat, variable)  {
  if(!is.null(variable)){
    if(is.character(variable))  {
      misVariable <- setdiff(variable, colnames(dat))
      if(length(misVariable) > 0) {
        stop(paste(length(misVariable)," variable(s) are not in dataset: ",
        paste(misVariable, collapse=", "), sep = ""))
      }
      varColumn <- match(variable, colnames(dat))
    }
    if(is.numeric(variable))   {varColumn <- variable}
    return(colnames(dat)[varColumn])
  }
  if(is.null(variable)) {return(NULL)}
}

Try the eatTools package in your browser

Any scripts or data that you put into this service are public.

eatTools documentation built on May 2, 2019, 4:44 p.m.