R/all.integers.R

Defines functions all.integers

# all.integers: robustly tests whether all elements of a vector are integers
# Date: March 31, 2026
all.integers <- function(x) {
  for (i in 1:length(x)) {
    if (is.na(x[i]) | is.list(x[i]) | length(x[i]) > 1 | !is.numeric(x[i])) {
      return(FALSE)
      }
    if (x[i]%%1!=0) {
      return(FALSE)
      }
    }
  return(TRUE)
  }

Try the dunn.test package in your browser

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

dunn.test documentation built on June 5, 2026, 5:06 p.m.