R/internal_helpers.R

Defines functions is_whole_number is_whole_positive

# Internal functions

## Check whether something is a whole number

is_whole_number <- function(x){
  if(is.integer(x)){
    TRUE
  } else if(is.numeric(x)){
    if((x%%1) == 0 ){
      TRUE
    } else {
      FALSE
    }
  } else {
    FALSE
  }
}

is_whole_positive <- function(x){
  if(is_whole_number(x) && x >= 0) TRUE else FALSE
}

Try the xnet package in your browser

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

xnet documentation built on Feb. 4, 2020, 9:10 a.m.