-
Notifications
You must be signed in to change notification settings - Fork 3
/
_targets.R
64 lines (53 loc) · 1.58 KB
/
_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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
library(targets)
library(tarchetypes)
library(crew) # parallel computing
controller <- crew::crew_controller_local(
name = "anvur_controller",
workers = 1
)
# Set target-specific options such as packages.
tar_option_set(
# error handling
error = "continue", # "null" create target with non-errored branches
workspace_on_error = TRUE,
# fast data formats
format = "qs",
# parallel computing
storage = "worker",
retrieval = "worker",
controller = controller
)
# Define custom functions and other global objects.
# This is where you write source(\"R/functions.R\")
# if you keep your functions in external scripts.
list.files(here::here("R"), pattern = "\\.R$", full.names = TRUE) |>
lapply(source) |> invisible()
# End this file with a list of target objects.
list(
# Import your file from custom (shared) location, and preprocess them
tar_files_input(
db_raw_path,
# get_input_data_path("db_raw.csv"), # single
get_input_data_path() |>
list.files(pattern = "\\.csv$", full.names = TRUE) # multiple
),
tar_target(db_raw, import_data(db_raw_path)),
tar_target(db, preprocess(db_raw)),
# Call your custom functions as needed.
tar_target(relevantResult, relevant_computation(db)),
# compile yor report
tar_render(report, here::here("reports/report.Rmd")),
# Decide what to share with other, and do it in a standard RDS format
tar_target(
objectToShare,
list(
relevant_result = relevantResult
)
),
tar_target(
shareOutput,
share_objects(objectToShare),
format = "file",
pattern = map(objectToShare)
)
)