Skip to content

Instantly share code, notes, and snippets.

@benjamin-chan
Last active August 24, 2016 19:58
Show Gist options
  • Save benjamin-chan/50d4ffd33acb2447be71eeb16eb5ba4f to your computer and use it in GitHub Desktop.
Save benjamin-chan/50d4ffd33acb2447be71eeb16eb5ba4f to your computer and use it in GitHub Desktop.
Template for R make file
setwd("H:/Projects") # Set project directory
Sys.time0 <- Sys.time()
sink("make.log")
files <- c("file1.Rmd", # File 1
"file2.Rmd", # File 2
"file3.Rmd") # File 3
f <- file("master.Rmd", open = "w")
for (i in 1:length(files)) {
x <- readLines(files[i])
writeLines(x, f)
if (i < length(files)) {writeLines("\n---\n", f)}
}
close(f)
library(knitr)
library(rmarkdown)
knit("master.Rmd", output = "index.md")
file.remove("master.Rmd")
sink("session.log")
list(completionDateTime = Sys.time(),
executionTime = Sys.time() - Sys.time0,
sessionInfo = sessionInfo())
sink()
sink()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment