公告
财富商城
积分规则
提问
发文
2020-03-31 23:34发布
戒情不戒烟
> 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
> format(round(1.20, 2), nsmall = 2) [1] "1.20" > format(round(1, 2), nsmall = 2) [1] "1.00" > format(round(1.1234, 2), nsmall = 2) [1] "1.12"
try this variation from this article so you can have more samples.
最多设置5个标签!
This is a bit clunky, but it will work and keep everything numeric:
Result:
try this variation from this article so you can have more samples.