diff --git a/Snakefile b/Snakefile index 48e9b30e..5bcef3e8 100644 --- a/Snakefile +++ b/Snakefile @@ -1,4 +1,5 @@ configfile: "config.yaml" +include: "rules/packrat.snakefile" include: "rules/preprocessing.snakefile" include: "rules/features.snakefile" include: "rules/reports.snakefile" @@ -37,25 +38,6 @@ rule all: expand("reports/figures/{pid}/compliance_heatmap.html", pid=config["PIDS"]), expand("reports/figures/{pid}/battery_consumption_rates_barchart.html", pid=config["PIDS"]), -# --- Packrat Rules --- # -## Taken from https://github.com/lachlandeer/snakemake-econ-r - -## packrat_install: installs packrat onto machine -rule packrat_install: +rule clean: shell: - "R -e 'install.packages(\"packrat\", repos=\"http://cran.us.r-project.org\")'" - -## packrat_install: initialize a packrat environment for this project -rule packrat_init: - shell: - "R -e 'packrat::init()'" - -## packrat_snap : Look for new R packages in files & archives them -rule packrat_snap: - shell: - "R -e 'packrat::snapshot()'" - -## packrat_restore: Installs archived packages onto a new machine -rule packrat_restore: - shell: - "R -e 'packrat::restore()'" \ No newline at end of file + "rm -rf data/raw/* && rm -rf data/interim/* && rm -rf data/processed/* && rm -rf reports/figures/* && rm -rf reports/*.zip" \ No newline at end of file diff --git a/rules/packrat.snakefile b/rules/packrat.snakefile new file mode 100644 index 00000000..bd46cccc --- /dev/null +++ b/rules/packrat.snakefile @@ -0,0 +1,22 @@ +# --- Packrat Rules --- # +## Taken from https://github.com/lachlandeer/snakemake-econ-r + +## packrat_install: installs packrat onto machine +rule packrat_install: + shell: + "R -e 'install.packages(\"packrat\", repos=\"http://cran.us.r-project.org\")'" + +## packrat_install: initialize a packrat environment for this project +rule packrat_init: + shell: + "R -e 'packrat::init()'" + +## packrat_snap : Look for new R packages in files & archives them +rule packrat_snap: + shell: + "R -e 'packrat::snapshot()'" + +## packrat_restore: Installs archived packages onto a new machine +rule packrat_restore: + shell: + "R -e 'packrat::restore()'" \ No newline at end of file