R/as_int.r

Defines functions .as_int

Documented in .as_int

#' Compare x to its round value
#' @param x a double
#' @noRd
.as_int<-function(x)
{if(!is.integer(x)) {
            xo = round(x)
            if(any(x > .Machine$integer.max))
                stop("the input has entries too large to be integer")
            if(!identical(TRUE, (ax <- all.equal(xo, x))))
                warning("the argument is not integer")
            else x=xo
        }
x
}

Try the sampling package in your browser

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

sampling documentation built on Nov. 2, 2023, 6:26 p.m.