Creation of plot using Action Button in R Shiny

543 views
Skip to first unread message

ashmink...@gmail.com

unread,
Sep 8, 2017, 2:34:53 AM9/8/17
to shinyapps.io Users
Hi, the following R script creates a shiny dashboard page with two buttons and one plot section. 
The second button "Processing" works fine but the first button "Resource" creates the process_map()
plot outside the shiny page in the output pane. I want a functionality where when I click on button "Resource",
it gives me the filter menu using "ifilter_resource",post that I should select the resources to be filtered,
and change happens to the process_map that I have built within the shiny page. Please help and big thanks.

## app.R ##
library(bupaR)
library(edeaR)
library(eventdataR)
library(processmapR)
library(processmonitR)
library(xesreadR)
library(petrinetR)

ui <- dashboardPage(
dashboardHeader(title = "Business Process Mining"),

dashboardSidebar(
width = 0,
conditionalPanel(condition = "input.tabselected == 1")
),
dashboardBody(

# Creation of tabs and tabsetPanel
tabsetPanel(type = "tab",
            tabPanel("Overview", value = 1,

                     fluidRow(
                       column(1,
                              tags$br(actionButton("buttonprocmapone", 
"Resource")),
                              tags$br(),
                              tags$br(actionButton("buttonprocmaptwo", 
"Processing"))
                       ),
                       tags$br(),


                       column(10,

                              plotOutput("proc_map_plot")
                       ))



            ))))
server <- function(input, output) { 

#Code for Resource Dashboard Resource Involvement Plots

proc_map <- reactiveValues(proc_map_one = 0, proc_map_two = 0)

observeEvent(input$buttonprocmapone, {
proc_map$proc_map_one <- 1
proc_map$proc_map_two <- 0

})

observeEvent(input$buttonprocmaptwo, {
proc_map$proc_map_one <- 0
proc_map$proc_map_two <- 1

})

output$proc_map_plot <- renderPlot(
{
  if(proc_map$proc_map_one)
    pt1 = ifilter_resource(patients)
    pt1 %>% process_map()
  else
    if(proc_map$proc_map_two)
      patients %>%resource_involvement("resource") %>% plot 
  else
    return()
}

)
}
shinyApp(ui, server)

Joshua Spiewak

unread,
Sep 8, 2017, 10:25:01 AM9/8/17
to shinyapps.io Users
Sounds like a general Shiny question better asked on the shiny-discuss list.

ashmink...@gmail.com

unread,
Sep 9, 2017, 5:57:00 AM9/9/17
to shinyapps.io Users
Hi @JoshuaSpiewak, thanks a lot for replying, I have this one issue which I am not able to resolve, this is a unique issue with a process map which needs a little thinking:


Please refer to the script below:

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)
Reply all
Reply to author
Forward
0 new messages