-
Notifications
You must be signed in to change notification settings - Fork 0
/
_targets_options.R
59 lines (39 loc) · 1.96 KB
/
_targets_options.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Libraries ---------------------------------------------------------------
if(!require(targets)) install.packages("targets"); library(targets)
if(!require(tarchetypes)) install.packages("tarchetypes"); library(tarchetypes)
# Set options, load packages -----------------------------------------------
# Source all /R files
targets::tar_source("R")
suppressWarnings(targets::tar_source("R_tasks"))
options(pillar.sigfig = 5)
# Packages to load
essential_packages = c(
# Main
"cli", "renv", "tarchetypes", "targets", "testthat", "visNetwork",
# Data preparation
"dplyr", "forcats", "here", "janitor", "purrr", "readr", "stringr", "tibble", "tidyr",
# Data analysis and visualization
"gtsummary", "patchwork", "psych", "DT", "ggplot2"
)
extra_packages = c(
# Extras
"furrr", "writexl", "broom", "broom.mixed", "emmeans", "gt", "irr", "lme4", "parameters", "performance", "ggalluvial", "ggridges",
# Non declared dependencies
"diffviewer", "qs", "webshot", "xml2", "jquerylib",
# Admin
"devtools", "gtools", "odbc"
)
packages_to_load = purrr::discard(c(essential_packages), is.na)
# Uncomment this for more functionality, and add your needed packages to extra_packages
# packages_to_load = purrr::discard(c(essential_packages, extra_packages), is.na)
# target options (packages, errors...)
tar_option_set(
# Load packages for all targets
packages = packages_to_load,
# If there is an error:
# tar_workspaces() # Lists the available workspaces (e.g. DF_clean)
# tar_workspace(DF_clean) # Loads the errored workspace
workspace_on_error = TRUE
)
# Make sure tests run always
if (file.exists("_targets/objects/TESTS") == TRUE ) targets::tar_invalidate(matches("TESTS"))