Indrajeet Patil
Indrajeet Patil

Reputation: 4879

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

I am using skimr::skim_to_wide function to look at the summary of my data. But I can't seem to figure out how to change the number of decimal places in the summary output for numeric variables.

For example, here the mean is always "3.22", but I'd like to get a more precise value like "3.21725". Note that I am using options(pillar.sigfig = 6) because skimr always 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>

Created on 2019-09-20 by the reprex package (v0.3.0)

Upvotes: 0

Views: 909

Answers (1)

Jonny Phelps
Jonny Phelps

Reputation: 2717

It does mention in the package docs that you can format the digits e.g. see skim_format function and skim_format(numeric=list(digits=4)). If you run this prior to skimr::skim_to_wide(mtcars$wt) it is now 4 digits

Was quite difficult to find!

Upvotes: 3

Related Questions