Last active
September 16, 2024 07:57
-
-
Save rkrug/9005f4b7169e65b6c51866209370c599 to your computer and use it in GitHub Desktop.
Makefile for R projects using the `targets` package.
This file contains hidden or 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
SHELL = /bin/bash | |
# run targets pipeline | |
build: | |
Rscript -e "targets::tar_make()" | |
# visnetwork | |
vis: visualise | |
visualise: | |
Rscript -e "targets::tar_visnetwork()" | |
# delete _targets folderas well as content of data folder | |
clean: | |
Rscript -e "targets::tar_destroy()" | |
rm -rf ./data/* | |
rm -rf ./Report.html | |
############# Help targets ############# | |
list_variables: | |
@echo | |
@echo "#############################################" | |
@echo "## Variables ################################" | |
@$(MAKE) -pn | grep -A1 "^# makefile"| grep -v "^#\|^--" | sort | uniq | |
@echo "#############################################" | |
@echo "" | |
## from https://stackoverflow.com/a/26339924/632423 | |
help: | |
@echo | |
@echo "#############################################" | |
@echo "## Make Targets #############################" | |
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | |
@echo "#############################################" | |
@echo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment