-
Notifications
You must be signed in to change notification settings - Fork 0
/
_targets.R
38 lines (29 loc) · 956 Bytes
/
_targets.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
36
37
suppressPackageStartupMessages({
library(targets)
library(tarchetypes)
})
options(tidyverse.quiet = TRUE, dplyr.summarise.inform = FALSE)
# attach R packages
required_packages <- read.delim("R/packages.txt", header = FALSE, col.names = "name")$name
tar_option_set(packages = required_packages, format = "qs")
# Create dirs if necessary
for (d in c("tab", "fig", "cache")) if (!dir.exists(d)) dir.create(d)
# for interactive session only
if (interactive()) sapply(required_packages, library, character.only = TRUE)
# load all functions from .R files
files_R <- list.files(c("R", "targets"), pattern = "*.R$", full.names = TRUE)
sr_ <- sapply(files_R, source)
# prevent other packages from stealing from tidyverse
filter <- dplyr::filter
rename <- dplyr::rename
select <- dplyr::select
slice <- dplyr::slice
# Add session info
sesinfo <- list(
tar_force(session_info, sessionInfo(), force = TRUE)
)
# Targets
c(
#sesinfo,
targets_main()
)