-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_targets.R
74 lines (58 loc) · 1.97 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
# Created by use_targets().
# Follow the comments below to fill in this target script.
# Then follow the manual to check and run the pipeline:
# https://books.ropensci.org/targets/walkthrough.html#inspect-the-pipeline
# Load packages required to define the pipeline:
library(targets)
library(httr)
library(lubridate)
library(janitor)
library(tidyverse)
library(stm)
library(tidytext)
# Set target options:
tar_option_set(
packages = c(
"tibble"
, "httr"
, 'lubridate'
, 'janitor'
) # packages that your targets need to run
)
# Set Execution Options
options(clustermq.scheduler = "multiprocess")
# ===== Source Code ====
tar_source(c(
"R/rUtils/dataCapture/apis.R"
, "R/1__dataPreparation.R"
))
# ===== Call Targets ====
list(
# ===== Call Data ====
tar_target(
name = extract__311raw
, command = getData_cartoDbMonthQuery(
baseQuery = "SELECT * FROM public_cases_fc WHERE CLOSED_DATETIME >= "
, monthsOfData = 6
)
),
# ==== TidyTize the Data and Cast to a DFM ====
tar_target(
name = transform__311tidyText
, command = create__tidyTextDataset(
extract__311raw
, stopwords = tidytext::stop_words
, text_field = "subject"
, document_field = "cartodb_id"
)
),
tar_target(
name = transform__311dfmText
, command = create__textMatrix(transform__311tidyText)
),
# ==== Utilize STM Model -- Tuning ====
tar_target(
name = stm
, stm::stm(transform__311dfmText,K = 6,verbose = FALSE, init.type = "Spectral")
)
)