R/isBinary.R

Defines functions isBinary

isBinary <-
function(arg) {
  binary <- TRUE
  arg <- as.matrix(na.exclude(arg))
  if (is.matrix(arg)) {
    u_mat <- unique(arg)
    for (each in u_mat) { 
      if (each != 0 && each != 1) { 
        binary <- FALSE; break
        } 
      } #breaks and returns FALSE as soon as it hits a non-missing, non (0,1) value
    return(binary) 
  } 
  else { 
    message('Blau dimension columns must be coercable to matrix')
  }
}

Try the Blaunet package in your browser

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

Blaunet documentation built on Sept. 27, 2022, 9:05 a.m.