-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.R
75 lines (56 loc) · 2.17 KB
/
main.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
##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
##
## Construct and run a Health Impact Assessment (HIA) pipeline
## Cassandra Yuen and Ivan Hanigan
##
##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
## use this helper download function
source("R/func_helpers/helper_install_pkgs.R")
install_pkgs(repos = getOption("repos")) # provide a repository URL if necessary
# Load libraries and functions --------------------------------------------
library(targets)
# Define global variables -------------------------------------------------
source('config.R')
# check data storage exists
if(length(grep("Environment_General", dir(dir_cardat))) == 0){
print("Environment_General folder not found, review your config.R")
} else {
print("Good to go")
}
# Run pipeline ------------------------------------------------------------
## visualise targets
tar_glimpse()
tar_manifest() # or get a tibble
## run pipeline
tar_make()
## visualise target status
tar_visnetwork(targets_only = T, level_separation = 200)
# click a target to highlight linked targets (use argument degree_to/degree_from to control number of edges to highlight, default 1)
# View target output ------------------------------------------------------
## table
# see results of specified target
tar_read(calc_attributable_number)
## maps
## with leaflet
library(leaflet)
tar_read(leaflet_an) %>% addProviderTiles("CartoDB.Positron")
## with ggplot
# tar_read(viz_an)
## view report
browseURL("report.html")
# Debugging help ----------------------------------------------------------
tar_meta(fields = warnings)
tar_meta(fields = error)
## lOad libraries here
# library(data.table)
# library(sf)
# library(raster)
## remove targets-generated files (options to selectively remove objects, metadata, etc.)
# tar_destroy()
## load target output from last successful build of target
# tar_read(data_study_pop_health)
## run a specific branch in debug mode - do not use callr_function = NULL in regular usage
# tar_option_set(debug = "health_impact_function")
# tar_make(names = health_impact_function, callr_function = NULL)
# tar_manifest(fields = "command")
# tar_glimpse(targets_only = FALSE)