Skip to content

Instantly share code, notes, and snippets.

@PirateGrunt
Created March 28, 2015 01:01
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save PirateGrunt/e8ec52fe412f5069f2a0 to your computer and use it in GitHub Desktop.
Save PirateGrunt/e8ec52fe412f5069f2a0 to your computer and use it in GitHub Desktop.
Basic makefile
####################
# Makefile
# Copyright Brian A. Fannin 2015
####################
RDIR = .
DATA_DIR = $(RDIR)/data
GATHER_DIR = $(DATA_DIR)/gather
GATHER_SOURCE = $(wildcard $(GATHER_DIR)/*.Rmd)
GATHER_OUT = $(GATHER_SOURCE:.Rmd=.docx)
PROCESS_DIR = $(DATA_DIR)/process
PROCESS_SOURCE = $(wildcard $(PROCESS_DIR)/*.Rmd)
PROCESS_OUT = $(PROCESS_SOURCE:.Rmd=.docx)
ANALYSIS_DIR = $(RDIR)/analysis
ANALYSIS_SOURCE = $(wildcard $(ANALYSIS_DIR)/*.Rmd)
ANALYSIS_OUT = $(ANALYSIS_SOURCE:.Rmd=.docx)
PRESENTATION_DIR = $(RDIR)/presentation
PRESENTATION_SOURCE = $(wildcard $(PRESENTATION_DIR)/*.Rmd)
PRESENTATION_OUT = $(PRESENTATION_SOURCE:.Rmd=.html)
KNIT = Rscript -e "require(rmarkdown); render('$<')"
all: $(GATHER_OUT) $(PROCESS_OUT) $(ANALYSIS_OUT) $(PRESENTATION_OUT)
#########################
## Gather
$(GATHER_DIR)/%.docx:$(GATHER_DIR)/%.Rmd
$(KNIT)
#########################
# Process
$(PROCESS_DIR)/%.docx:$(PROCESS_DIR)/%.Rmd $(GATHER_OUT)
$(KNIT)
#########################
# Analyze
$(ANALYSIS_DIR)/%.docx:$(ANALYSIS_DIR)/%.Rmd $(PROCESS_OUT)
$(KNIT)
#########################
# Present
$(PRESENTATION_DIR)/%.docx:$(PRESENTATION_DIR)/%.Rmd $(ANALYSIS_OUT)
$(KNIT)
clean:
rm -fv $(GATHER_OUT)
rm -fv $(PROCESS_OUT)
rm -fv $(ANALYSIS_OUT)
rm -fv $(PRESENTATION_OUT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment