generated from byu-transpolab/template_bookdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_targets.R
108 lines (88 loc) · 5.23 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
library(targets)
# This is an example _targets.R file. Every
# {targets} pipeline needs one.
# Use tar_script() to create _targets.R and tar_edit()
# to open it again for editing.
# Then, run tar_make() to run the pipeline
# and tar_read(summary) to view the results.
# Define custom functions and other global objects.
# This is where you write source(\"R/functions.R\")
# if you keep your functions in external scripts.
source("R/data_functions.R")
source("R/analysis_functions.R")
source("R/plot_functions.R")
# Set target-specific options such as packages.
tar_option_set(packages = c("tidyverse", "readxl", "lubridate", "zoo",
"modelsummary", "kableExtra", "RColorBrewer"))
# debugging: uncomment tar_option_set with the name of the target to debug
# Then run tar_make with callr_function = NULL
# tar_option_set(debug = "adjusted_univ_data") # uncomment to debug
# tar_make(callr_function = NULL) # leave commented! run this in your console
# End this file with a list of target objects.
list(
# data cleaning and grouping pipeline
tar_target(raw_detector_data, read_raw_data(c("data/layton_detector.xlsx",
"data/bangerter_detector.xlsx",
"data/university_detector.xlsx",
"data/pgblvd_detector.xlsx"),
c("Layton", "Bangerter", "University", "PG_Blvd"))),
tar_target(raw_manual_data, read_raw_data(c("data/layton_manual.xlsx",
"data/bangerter_manual.xlsx",
"data/university_manual.xlsx",
"data/pgblvd_manual.xlsx"),
c("Layton", "Bangerter", "University", "PG_Blvd"))),
tar_target(adjusted_bgt_data, adjust_timebins(raw_detector_data$Bangerter, raw_manual_data$Bangerter)),
tar_target(adjusted_lyt_data, adjust_timebins(raw_detector_data$Layton, raw_manual_data$Layton)),
tar_target(adjusted_univ_data, adjust_timebins(raw_detector_data$University, raw_manual_data$University)),
tar_target(adjusted_pg_data, adjust_timebins(raw_detector_data$PG_Blvd, raw_manual_data$PG_Blvd)),
tar_target(df_bgt, clean_data(adjusted_bgt_data)),
tar_target(df_lyt, clean_data(adjusted_lyt_data)),
tar_target(df_univ, clean_data(adjusted_univ_data)),
tar_target(df_pg, clean_data(adjusted_pg_data)),
tar_target(nested_data, nest_data(list(df_bgt, df_lyt, df_univ, df_pg))),
tar_target(nested_data30, nest_data(list(df_bgt, df_lyt, df_univ, df_pg), bin_length = 30)),
tar_target(nested_data60, nest_data(list(df_bgt, df_lyt, df_univ, df_pg), bin_length = 60)),
tar_target(correlation_data, get_correlation_data(nested_data)),
tar_target(correlation_data30, get_correlation_data(nested_data30)),
tar_target(correlation_data60, get_correlation_data(nested_data60)),
# data analysis and plotting functions
tar_target(group_k, group_optimize_k(nested_data)),
tar_target(group_k30, group_optimize_k(nested_data30)),
tar_target(group_k60, group_optimize_k(nested_data60)),
# make plot data
tar_target(plot_data, make_plot_data(group_k)),
tar_target(plot_data30, make_plot_data(group_k30)),
tar_target(plot_data60, make_plot_data(group_k60)),
# Put correlation data and optimal groupings on the same df
tar_target(model_data, join_correlation_data(group_k, correlation_data)),
tar_target(model_data30, join_correlation_data(group_k30, correlation_data30)),
tar_target(model_data60, join_correlation_data(group_k60, correlation_data60)),
# make data analysis tables
tar_target(linearmodels, linear_models(model_data)),
tar_target(modelsummary, model_summary(linearmodels)),
# cluster analysis
tar_target(cluster_data, build_clusters(model_data)),
tar_target(cluster_data30, build_clusters(model_data30)),
tar_target(cluster_data60, build_clusters(model_data60)),
tar_target(cluster_plot, plot_clusters(cluster_data)),
tar_target(cluster_plot30, plot_clusters(cluster_data30)),
tar_target(cluster_plot60, plot_clusters(cluster_data60)),
tar_target(cluster_estimates, estimate_cluster_k(cluster_data)),
tar_target(cluster_estimates30, estimate_cluster_k(cluster_data30)),
tar_target(cluster_estimates60, estimate_cluster_k(cluster_data60)),
# Queue length estimates and RMSE
tar_target(pdata, predicted_queues(linearmodels, model_data)),
tar_target(pdata_plot, plot_predicted_queues(pdata)),
tar_target(rmse_bgt, rmse_data(pdata, "Bangerter")),
tar_target(rmse_lyt, rmse_data(pdata, "Layton")),
tar_target(rmse_univ, rmse_data(pdata, "University")),
tar_target(rmse_pg, rmse_data(pdata, "PG_Blvd")),
tar_target(rmse_table, rmse_data(pdata)),
# Wait time estimates and RMSE
tar_target(wttime_plot, wait_times(pdata)),
tar_target(rmse_wt_bgt, rmse_waittime_data(pdata, "Bangerter")),
tar_target(rmse_wt_lyt, rmse_waittime_data(pdata, "Layton")),
tar_target(rmse_wt_univ, rmse_waittime_data(pdata, "University")),
tar_target(rmse_wt_pg, rmse_waittime_data(pdata, "PG_Blvd")),
tar_target(rmse_wt, rmse_waittime_data(pdata))
)