I can control the decimals in the output of skimr in this way:
library(skimr)
options(pillar.sigfig = 2)
skim(faithful)
but I need to be able to output the results to a csv file. Doing this, the decimals are not affected. How can I modify the decimal output of tibbles for export to a csv?
options(pillar.sigfig = 2)
skim(faithful)%>%
write.csv("~/test.csv")
skimr::skim()
uses the pillar package to print the underlying skim_df
object in the console. If you write the skim_df
to a csv file, printing options are not considered.
You can treat the skim_df
like a tibble
or data.frame
. The code below shortens the decimals to 2 for all numeric columns in the skim_df
object.
library(skimr)
library(dplyr)
skim(faithful) |>
mutate(across(where(is.numeric), round, 2)) |>
write.csv("test.csv")