-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.R
More file actions
86 lines (72 loc) · 1.7 KB
/
Copy pathsetup.R
File metadata and controls
86 lines (72 loc) · 1.7 KB
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
suppressPackageStartupMessages({
options(repos = c(CRAN = "https://cloud.r-project.org"))
})
project_seed <- 20260424L
required_packages <- c(
"renv",
"targets",
"tarchetypes",
"tidyverse",
"tidymodels",
"future",
"furrr",
"here",
"janitor",
"lubridate",
"slider",
"yardstick",
"patchwork",
"ggrepel",
"ggtext",
"gt",
"qs2",
"broom",
"vip",
"DALEX",
"xgboost",
"fs",
"cli"
)
project_directories <- c(
"data/raw",
"data/processed/bronze",
"data/processed/silver",
"data/processed/gold",
"outputs/figures",
"outputs/tables",
"outputs/forecasts",
"outputs/diagnostics",
"outputs/qa"
)
install_if_missing <- function(packages) {
missing_packages <- packages[!vapply(packages, requireNamespace, logical(1), quietly = TRUE)]
if (length(missing_packages) == 0) {
return(invisible(NULL))
}
install.packages(missing_packages)
}
setup_project <- function() {
for (directory in project_directories) {
fs::dir_create(here::here(directory), recurse = TRUE)
}
if (!requireNamespace("renv", quietly = TRUE)) {
install.packages("renv")
}
if (file.exists(here::here("renv.lock"))) {
renv::restore(project = here::here(), prompt = FALSE)
}
install_if_missing(required_packages)
set.seed(project_seed)
options(
dplyr.summarise.inform = FALSE,
readr.show_col_types = FALSE,
tidymodels.dark = FALSE,
width = 120
)
cli::cli_h1("WMATA project setup complete")
cli::cli_alert_success("Project directories are present.")
cli::cli_alert_success("Required packages are installed or restored.")
cli::cli_alert_info("Run targets::tar_make() from the project root to execute the pipeline.")
invisible(TRUE)
}
setup_project()