问题
The script below when executed creates a process_map() with a select input. Upon selecting a resource like "r1","r2" etc. we get the corresponding process map. However I want to dynamically pass an input from the selectInput bar and update the process map within R shiny page Snapshot for your reference. Please help.
## app.R ##
install.packages("bupaR")
install.packages("edeaR")
install.packages("eventdataR")
install.packages("processmapR")
install.packages("processmonitR")
install.packages("xesreadR")
install.packages("petrinetR")
install.packages("shiny")
install.packages("shinydashboard")
library(shiny)
library(shinydashboard)
library(bupaR)
library(edeaR)
library(eventdataR)
library(processmapR)
library(processmonitR)
library(xesreadR)
library(petrinetR)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
selectInput("resources","Select the resource", c("r1","r2","r3","r4","r5"),
selected = "r1",selectize = T)
),
dashboardBody(
filter_resource(patients,resources = c("r1","r2","r4"), reverse = F) %>%
process_map()
))
server <- function(input, output) {
}
shinyApp(ui, server)
回答1:
You could do
library(shiny)
library(shinydashboard)
library(bupaR)
library(edeaR)
library(eventdataR)
library(processmapR)
library(processmonitR)
library(xesreadR)
library(petrinetR)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
selectInput("resources","Select the resource", c("r1","r2","r3","r4","r5"),selected = "r1",selectize = T)
),
dashboardBody(
uiOutput("ui")
))
server <- function(input, output) {
output$ui <- renderUI({
r <- input$resources
tagList(filter_resource(patients,resources = r, reverse = F) %>% process_map())
})
}
shinyApp(ui, server)
来源:https://stackoverflow.com/questions/46128437/passing-dynamic-input-and-updating-visual-in-r-shiny