-
Notifications
You must be signed in to change notification settings - Fork 1
/
_targets.R
160 lines (147 loc) · 4.12 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Created by use_targets().
# Package loading and config setup ----------------------------------------
# Load packages required to define the pipeline:
library(targets)
library(magrittr)
library(tarchetypes)
# Set target options:
tar_option_set(
# packages that your targets need to run
packages = c("lubridate")
)
# Run the R scripts in the R/ folder with your custom functions:
tar_source()
# Force re-running everything
# targets::tar_destroy()
run_if_course_month_away <- function() {
upcoming <- get_upcoming_course()
if (is.na(upcoming)) {
return(FALSE)
}
closest_date <- upcoming |>
get_upcoming_course_dates() |>
lubridate::ymd()
dplyr::between(
lubridate::today(),
closest_date - months(1),
closest_date
)
}
# Replace the target list below with your own:
list(
# Upcoming (soonest) ------------------------------------------------------
tar_force(
name = upcoming_precourse_survey,
command = if (!is.na(get_upcoming_course())) {
get_precourse_survey(get_upcoming_course()) |>
dplyr::filter(course_date == max(course_date))
} else {
NA
},
force = run_if_course_month_away()
),
# tar_target(
# name = participants_not_complete_survey,
# command =
# ),
# tar_target(
# name = participants_with_problems,
# command =
# ),
# tar_target(
# name = check_setups,
# command =
# ),
# tar_target(
# name = create_team_pdfs,
# command = ,
# format = "file"
# ),
tar_target(
name = course_ids,
command = list_course_ids()
),
# Pre-course survey -------------------------------------------------------
tar_target(
name = precourse_surveys,
command = get_precourse_survey(course_ids),
pattern = map(course_ids)
),
tar_target(
name = participant_overview,
command = extract_participant_overview(precourse_surveys),
pattern = map(precourse_surveys)
),
tar_target(
name = saved_participant_overview,
command = participant_overview |>
dplyr::mutate(type = "overview") |>
save_responses_to_csv(c("course_id", "course_date", "type")),
format = "file"
),
# Feedback ----------------------------------------------------------------
tar_target(
name = precourse_feedback,
command = extract_precourse_feedback(precourse_surveys),
pattern = map(precourse_surveys)
),
tar_target(
name = course_ids_feedback,
command = c(list_course_ids(), "general")
),
tar_target(
name = feedback_survey,
command = get_feedback_survey(course_ids_feedback),
pattern = map(course_ids_feedback)
),
tar_target(
name = feedback_survey_overall,
command = extract_feedback_overall(feedback_survey),
pattern = map(feedback_survey)
),
tar_target(
name = feedback_survey_quantitative,
command = extract_feedback_quantitative(feedback_survey),
pattern = map(feedback_survey)
),
tar_target(
name = feedback_survey_sessions,
command = extract_feedback_sessions(feedback_survey),
pattern = map(feedback_survey)
),
# Save to file -----------------------------------------------------------
tar_target(
name = combined_feedback,
command = list(
list(
data = feedback_survey_overall |>
dplyr::mutate(type = "feedback-overall"),
columns = c("course_id", "course_date", "type")
),
list(
data = feedback_survey_quantitative |>
dplyr::mutate(type = "feedback-quantitative"),
columns = c("course_id", "course_date", "type")
),
list(
data = feedback_survey_sessions |>
dplyr::mutate(type = "feedback-sessions"),
columns = c("course_id", "course_date", "type", "date")
),
list(
data = precourse_feedback |>
dplyr::mutate(type = "feedback-precourse"),
columns = c("course_id", "course_date", "type")
)
)
),
tar_target(
name = saved_feedback_sessions_paths,
command = combined_feedback |>
purrr::map(\(feedback) save_responses_to_csv(feedback$data, feedback$columns)) |>
unlist(),
pattern = map(combined_feedback),
iteration = "list",
format = "file"
)
)