-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
41 lines (32 loc) · 1.44 KB
/
server.R
File metadata and controls
41 lines (32 loc) · 1.44 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
server <- function(input, output, session){
# create all roster selection inputs
output$rosterSelections <- renderUI({
shinydashboard::box(title = "Select your roster:", solidHeader = TRUE, width = 12,
status = "info", height = "100%",
lapply(1:length(rosterFormation), function(x){
pos <- rosterFormation[x]
do.call(selectInput,
list(inputId = paste0(pos, x),
label = pos,
choices = c("None", unique(scores_2019[which(scores_2019$Pos == pos), "Player"]))
)
)# end do.call
})# end lapply
)# end box
})# end renderUI
observeEvent(
# trigger this observeEvent when any of the dynamically generated inputs are changed
lapply(1:length(rosterFormation), function(x)
input[[paste0(rosterFormation[x], x)]]
),{
# initialize players vector
players <- c()
# go through all inputs and add them to a reactive values object
for(x in 1:length(rosterFormation)){
pos <- rosterFormation[x]
players <- c(players, input[[paste0(pos, x)]])
}# end for x loop
# add logic for figures
mod_figures_server("figures", players)
})# end observeEvent
}# end server