Ho utilizzato un makefile per automatizzare l'esecuzione di Sweave per i miei report di analisi in R utilizzando l'approccio delineato da Jeromy Anglim con grande successo. Recentemente ho sentito parlare del pacchetto cacheSweave e vorrei incorporare questa funzionalità nel mio file Rnw. Io uso il pacchetto ProjectTemplate per caricare tutti i file necessari all'avvio, e questo richiede un po 'di tempo perché devo pre-processare i file di dati grezzi. Gli esempi nella vignetta spettacolo cacheSweave come eseguire Sweave con il driver cacheSweave all'interno di una sessione R:Come utilizzare cacheSweave in un batch Chiamata di sweave tramite make?
library(cacheSweave)
Sweave("foo.Rnw", driver = cacheSweaveDriver)
Come Vorrei utilizzare il cacheSweaveDriver nel mio comando da eseguire Sweave in modalità batch? Nel mio makefile questo è come invoco Sweave:
$(TEXFILE).tex: $(TEXFILE).Rnw
R CMD SWeave $(TEXFILE).Rnw
R CMD Stangle $(TEXFILE).Rnw
Sto usando Emacs + ESS per creare il file ed eseguire .Rnw fare. Ecco il resto della mia makefile per riferimento:
TEXFILE=report_presentation
PLOTDIR= ../graphs
PLOTS=
FIGURES= $(PLOTDIR)/$(PLOTS)
INPUTS=
all: $(TEXFILE).pdf; make clean
.PHONY: all clean
$(TEXFILE).pdf: $(TEXFILE).tex $(FIGURES) $(INPUTS)
# Initial run
pdflatex $(TEXFILE)
# Run bibtex if missing citations
@if(grep "Citation" $(TEXFILE).log > /dev/null);\
then \
bibtex $(TEXFILE);\
pdflatex $(TEXFILE); \
fi
# Recompile if instructed
@if(grep "Rerun" $(TEXFILE).log > /dev/null);\
then \
pdflatex $(TEXFILE); \
fi
$(TEXFILE).tex: $(TEXFILE).Rnw
R CMD Sweave $(TEXFILE).Rnw
R CMD Stangle $(TEXFILE).Rnw
## Remove unnecessary files
clean:
-rm -f $(TEXFILE).log $(TEXFILE).aux $(TEXFILE).out $(TEXFILE).blg $(TEXFILE).bbl $(TEXFILE).nav $(TEXFILE).snm $(TEXFILE).toc Rplots.pdf