-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.R
51 lines (42 loc) · 1.03 KB
/
functions.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
# Level Functions ----------------------
# Input Level Functions
levelLabel <- function(lflag, subtractMod = 0) {
switch(lflag - subtractMod,
"level_one",
"level_two",
"level_three",
"level_four",
"level_five",
"level_six",
"level_seven")
#Call: levelLabel(level_flag())
# Or: levelLabel(2)
}
# Check if we should render
checkRender <- function(inputLevel, pflag) {
check <- FALSE
if (!is.null(inputLevel)) {
if (pflag == TRUE & inputLevel != "") {
check <- TRUE
}
}
return(check)
}
# Get options from framework
getOptions <- function(q_data) {
# Check if its terminal node
node_or_chart <- if (!is.na(q_data[["node_targets"]])) {
"node_targets"
} else {
"chart"
}
setNames(c("", makeList(q_data,node_or_chart)),
c("", makeList(q_data,"options")))
}
# Turn node_target and chart into lists
makeList <- function(q_data, colName) {
unique(q_data[[colName]]) %>%
strsplit(",") %>%
flatten() %>%
map(trimws)
}