Last active
October 10, 2017 18:11
-
-
Save potterzot/0ead18ad52ec77f6b47843349a933d25 to your computer and use it in GitHub Desktop.
Using Make to compile multiple Rmd files in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This lets you type `make` | |
# and will pandoc all *.Rmd files in the letters directory | |
# into pdfs stored in the output directory | |
all: readme letters | |
#generate all letters | |
SRC=$(wildcard letters/*.Rmd) | |
OUT=$(patsubst letters/%.Rmd, output/%.pdf, $(SRC)) | |
letters: $(OUT) | |
#CLEAN | |
#remove any output (non-data) files | |
clean: | |
rm -f README.md | |
cleanall: | |
rm -f README.md | |
rm -f output/* | |
#OUTPUT | |
#Project README | |
readme: README.Rmd | |
R -e "rmarkdown::render('$(<F)')" | |
#Generate a specific letter | |
output/%.pdf: letters/%.Rmd | |
cd $(<D); R -e "rmarkdown::render('$(<F)', output_format = 'all', output_dir = '../output/')" | |
#output/$(OUT): $(SRC) | |
# cd $(<D); R -e "rmarkdown::render('$(<F)', output_format = 'all', output_dir = '../output/')" | |
#output/%: $(SRC) | |
# cd letters; R -e "lapply($@, rmarkdown::render, output_format = 'all')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment