I have the shiny app below in which I create a process map. What I want to do is subset this process map based on the transitions selectInput().
All the transitions can be seen from the obect edges which I extract from the process_map() object at the beginning but then how can I pass the selected from the selectInput() again to the process_map() object?what I acually need is to hide/display the edges between the nodes if deselect/select one transition pair
library(shiny)
library(bupaR)
library(svgPanZoom)
library(DiagrammeR)
library(DiagrammeRsvg)
library(processmapR)
edges<-patients %>%
process_map(performance(mean, "days"))
edges <- attr(edges, "edges")
colnames(edges)[1]<-"predecessor"
colnames(edges)[2]<-"successor"
ui <-shinyUI(fluidPage(
selectInput("tran","transitions",choices = paste(edges$predecessor,"-",edges$successor),
selected = paste(edges$predecessor,"-",edges$successor),multiple=T),
svgPanZoomOutput("pmap",height = 500,width = 1600)
))
server <- function(input, output) {
output$pmap <- renderSvgPanZoom({
process_map(patients, type_nodes = frequency("absolute",color_scale = "Greys"),type_edges = frequency("absolute",color_edges = "Greys"),
rankdir = "LR", render = FALSE) %>%
generate_dot() %>%
grViz(width = 1000, height = 2000) %>%
export_svg %>%
svgPanZoom(height=800, controlIconsEnabled = TRUE)
})
}
shinyApp(ui=ui,server=server)
EDIT
With new understanding that the goal is to filter out a specific transition/edge, one way of doing it is to manipulate the graph as I couldn't really understand
process_mapdocumentation. DiagrammeR` documentation was much better http://rich-iannone.github.io/DiagrammeR/docs.htmlRunning example below. Notice that the main graph is built once, and after selecting a specific filter it is duplicated, and manipulated (finding and removing the edge).
With this example you should be able adjust to your specific case (use RStudio debugging for inspecting variables, and so on).
Can't really tell what exactly you want to achieve, but the general idea is that you need to use the selected transition, represented by
input$tran, to filter the data.My naive guess to filter the raw source data would be something like this:
Notice the parsing of the selected transition and later filtering the patients list.
This will consider only the nodes directly participating in the selected transition, which might not be what you need (e.g.: you could want to display 'inner-processes, but that means the current transition list is not adequate).
Other potential needs not easy to achieve with simple dataframe filtering would be to filter the process up to the selected transition (or all process after the actual transition until finishes). That would require filtering after the
process_mapcalculation (and I'm not in position to recommend how)