forked from PierreMasselot/EUcityProj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_shinyapps.R
More file actions
58 lines (49 loc) · 1.92 KB
/
deploy_shinyapps.R
File metadata and controls
58 lines (49 loc) · 1.92 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
################################################################################
# Deploy to shinyapps.io
#
# Prerequisites:
# 1. Create a free or paid account at https://www.shinyapps.io
# 2. Run rsconnect::setAccountInfo(...) once with your token
# 3. Run this script or source it in RStudio
#
# The dashboard/data/ folder must exist (run prep_deploy_data.R first).
# Data is now Hive-partitioned by URAU_CODE to avoid OOM on the server.
################################################################################
if (!requireNamespace("rsconnect", quietly = TRUE)) {
install.packages("rsconnect")
}
library(rsconnect)
# Check data exists (now partitioned directory instead of single file)
if (!dir.exists("dashboard/data/tmeanproj")) {
cat("Partitioned data not found. Running prep_deploy_data.R first...\n")
source("dashboard/prep_deploy_data.R")
}
# Check precomputed data exists (RR surfaces + vcov)
if (!dir.exists("dashboard/data/precomputed")) {
cat("Precomputed RR data not found. Running precompute_rr.R first...\n")
source("dashboard/precompute_rr.R")
}
# Build file list: app.R + csv files + partitioned parquet + precomputed
parquet_files <- list.files("dashboard/data/tmeanproj",
recursive = TRUE, full.names = FALSE)
parquet_files <- file.path("data/tmeanproj", parquet_files)
precomp_files <- list.files("dashboard/data/precomputed",
recursive = TRUE, full.names = FALSE)
precomp_files <- file.path("data/precomputed", precomp_files)
app_files <- c(
"app.R",
parquet_files,
precomp_files,
"data/coefs.csv",
"data/city_lookup.csv"
)
cat(sprintf("Deploying %d files (including %d partition files)...\n",
length(app_files), length(parquet_files)))
# Deploy
deployApp(
appDir = "dashboard",
appName = "climate-mortality-dashboard",
appTitle = "Climate–Mortality Pipeline Dashboard",
appFiles = app_files,
forceUpdate = TRUE
)