R/get_var_type.R

Defines functions get_var_type

get_var_type <- function(x){

  if(is.double(x)){
    return('ctns')
  }

  if(is.integer(x)){
    return('intg')
  }

  if(is.factor(x)){

    n_lvls <- length(levels(x))

    if(n_lvls == 2){
      return('bnry')
    } else {
      return('catg')
    }

  }

  stop("incompatible variable type <", class(x)[1], "> in data")

}
bcjaeger/ipa documentation built on May 7, 2020, 9:45 a.m.