3 回答

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超9個(gè)贊
背景:signif
, options(digits=...)
解:
x
.
format(round(x, 2), nsmall = 2)
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"
x
k
trimws
specify_decimal <- function(x, k) trimws(format(round(x, k), nsmall=k))
specify_decimal(1234, 5)# [1] "1234.00000"specify_decimal(0.1234, 5)# [1] "0.12340"

TA貢獻(xiàn)1744條經(jīng)驗(yàn) 獲得超4個(gè)贊
> # devtools::install_github("renkun-ken/formattable")> library(formattable)> x <- formattable(1.128347132904321674821, digits = 2, format = "f")> x[1] 1.13
x
> x + 1[1] 2.13
> formattable(x, digits = 6, format = "f")[1] 1.128347
- 3 回答
- 0 關(guān)注
- 751 瀏覽
添加回答
舉報(bào)