Learn R Programming

tidystats (version 0.3)

write_stats: Save the results in a tidy stats list to a .csv file

Description

write_stats converts a tidy stats results list to a data frame and then saves the data to a .csv file.

Usage

write_stats(results, path)

Arguments

results

A tidy stats list.

path

Path or connection to write to.

Details

The prettyNum function is used to format the numbers before saving them to disk. This is to prevent saving numbers with many decimals.

Examples

Run this code
# NOT RUN {
library(dplyr)

# Create an empty list to store the results in
results <- list()

# Conduct statistical tests
model1 <- t.test(anxiety ~ condition, data = cox)
model2 <- cor.test(cox$anxiety, cox$avoidance)

# Add output to the results list
results <- results %>%
  add_stats(model1, identifier = "M1") %>%
  add_stats(model2, identifier = "M2")

# Save the results
dir <- tempdir()
write_stats(results, file.path(dir, "results.txt"))

# }

Run the code above in your browser using DataLab