R/round2.R

Defines functions round2

Documented in round2

## File Name: round2.R
## File Version: 0.06

round2 <- function( vec, digits=0 )
{
    vec0 <- vec
    eps <- 1E-10
    vec <- abs(vec)
    vec <- vec*10^digits
    vec2 <- vec-floor(vec)
    vec <- floor( vec ) + ifelse( ( vec2 - .5 ) < - eps, 0, 1 )
    vec.round <- sign(vec0) * vec / 10^digits
    return(vec.round)
}

Try the miceadds package in your browser

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

miceadds documentation built on May 29, 2024, 11:05 a.m.