Skip to content

Instantly share code, notes, and snippets.

@actuaryactually
Created December 29, 2016 07:03
Show Gist options
  • Save actuaryactually/9a8c7f39db56f2aa70b590c490d18d01 to your computer and use it in GitHub Desktop.
Save actuaryactually/9a8c7f39db56f2aa70b590c490d18d01 to your computer and use it in GitHub Desktop.
Formatting Tools
setwd("C:/OldWorld/Blog/DataWrangling")
#Output console results to file:
# anova test
anova_test = aov(yield ~ block + N * P + K, npk)
anova_test
# t test
t_test = t.test(1:10, y = c(7:20))
t_test
##Now write both results to file:
# Title
cat("Tests Output", file = "tests.txt")
# add 2 newlines
cat("\n\n", file = "tests.txt", append = TRUE)
# export anova test output
cat("Anova Test\n", file = "tests.txt", append = TRUE)
capture.output(anova_test, file = "tests.txt", append = TRUE)
# add 2 newlines
cat("\n\n", file = "tests.txt", append = TRUE)
# export t-test output
cat("T-Test\n", file = "tests.txt", append = TRUE)
capture.output(t_test, file = "tests.txt", append = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment