> signif(1.89,digits=2) [1] 1.9
I\'d like to have 1.8
This is a bit clunky, but it will work and keep everything numeric:
x <- 1.829380 trunc.dec <- function(x,n) { floor(x*10^n)/10^n }
Result:
trunc.dec(x,1) #[1] 1.8 trunc.dec(x,2) #[1] 1.82 trunc.dec(x,3) #[1] 1.829 trunc.dec(x,4) #[1] 1.8293