write_stats()
writes a tidystats list to a .json file.
Examples
# Conduct a statistical test
sleep_wide <- reshape(
sleep,
direction = "wide",
idvar = "ID",
timevar = "group",
sep = "_"
)
sleep_test <- t.test(sleep_wide$extra_1, sleep_wide$extra_2, paired = TRUE)
# Create an empty list
statistics <- list()
# Add statistics to the list
statistics <- add_stats(statistics, sleep_test)
# Save the statistics to a file
dir <- tempdir()
write_stats(statistics, file.path(dir, "statistics.json"))