R/sigfig.R

Defines functions sigfig

Documented in sigfig

sigfig <-
function(t,d){
    old.o <- options(scipen=4)                  ## Fixes default scientific notation
    v1 <- format(round(t,d),digits=d+1,trim=T)  ## Fixes digits for sig2, and any leading-white-space
    v2 <- format(signif(t,1),scientific=T)
    swap <- abs(t)<=10^(-d)
    v1[swap] <- v2[swap]
    options(scipen=old.o$scipen)
    return(v1)
}

Try the safe package in your browser

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

safe documentation built on Nov. 8, 2020, 5:37 p.m.