forked from UBC-MDS/air-pollution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocalize-dataset.R
34 lines (26 loc) · 919 Bytes
/
localize-dataset.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
source("config.R")
globalVariables(c("NAPS_dataset_path"))
if (startsWith(NAPS_dataset_path, "http://") ||
startsWith(NAPS_dataset_path, "https://")) {
cat("Dataset path seems to be a compatible remote resource\n")
cat("Downloading\n")
url <- NAPS_dataset_path
new_dataset_path <- paste0("data/", basename(NAPS_dataset_path))
download.file(url, new_dataset_path)
cat("Done\n")
cat("Writing the new dataset path to config.R\n")
cat(paste(
"",
"",
"# ===========================",
"# ADDED BY localize-dataset.R",
paste0("NAPS_dataset_path <- '", new_dataset_path, "'"),
"# ===========================",
"",
sep = "\n"
), file = "config.R", append = TRUE)
cat("Done\n")
} else {
cat("Dataset path does not seem to be a compatible remote resource\n")
cat("Exiting\n")
}