R/is.constant.R

is.constant <-  function(x) {
  if (is.factor(x)) {
    res <- (length(attributes(x)$levels) == 1) && !any(is.na(as.character(x)))
  } else {
    res <- is.numeric(x) && !any(is.na(x)) && identical(min(x), max(x))
  }
  return(res)
}

Try the cwhmisc package in your browser

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

cwhmisc documentation built on May 1, 2019, 7:55 p.m.