更改数字变量的 `skimr` 输出中的小数位数

changing the number of decimal places in `skimr` output for numeric variables

我正在使用 skimr::skim_to_wide 函数查看我的数据摘要。但我似乎无法弄清楚如何更改数字变量摘要输出中的小数位数。

例如,这里的平均值始终是 "3.22",但我想获得更精确的值,例如 "3.21725"。请注意,我使用 options(pillar.sigfig = 6) 因为 skimr 总是 returns a tibble

options(digits = 6)
mean(mtcars$wt)

#> [1] 3.21725

options(pillar.sigfig = 6)
skimr::skim_to_wide(mtcars$wt)

#> # A tibble: 1 x 13
#>   type  variable missing complete n     mean  sd    p0    p25   p50   p75  
#>   <chr> <chr>    <chr>   <chr>    <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 nume~ x        0       32       32    3.22  0.98  1.51  2.58  3.33  3.61 
#> # ... with 2 more variables: p100 <chr>, hist <chr>

reprex package (v0.3.0)

于 2019-09-20 创建

它确实在 package docs 中提到您可以格式化数字,例如请参阅 skim_format 函数和 skim_format(numeric=list(digits=4))。如果你在 skimr::skim_to_wide(mtcars$wt) 之前 运行 它现在是 4 位数

好难找!