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

Description Usage Arguments Details Examples

View source: R/write_stats.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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"))

WillemSleegers/tidystats-v0.3 documentation built on Aug. 12, 2019, 5:31 p.m.