-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile.R
35 lines (26 loc) · 989 Bytes
/
makefile.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Load packages.
library(package = rprojroot) # find files in sub-directories
library(package = purrr) # functional programming
# Locate code.
root_path <- rprojroot::find_root(criterion = rprojroot::has_dirname(dirname = "hrs"),
path = ".")
# Run code.
hrs_code <- c("1_hrs.R",
"2_hrs.R",
"3_hrs.R",
"4_hrs.R") %>%
purrr::map(.f = function(x) file.path(root_path,
"code",
x,
fsep = "/"))
purrr::map(.x = hrs_code,
.f = source)
# Remove intermediate files.
hrs_intermediate <- c("1_hrs.feather",
"2_hrs.feather",
"3_hrs.feather") %>%
purrr::map(.f = function(x) file.path(root_path,
x,
fsep = "/")) %>%
unlist
file.remove(hrs_intermediate)