Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.49 KB | None | 0 0
  1. library(shiny)
  2. library(pool)
  3. library(shinydashboard)
  4.  
  5. ui <- fluidPage(
  6.  
  7.  
  8. actionButton("load_scenario","load scenario"),
  9. uiOutput("input")
  10.  
  11. )
  12.  
  13.  
  14. dashboar <- function(x){
  15.  
  16.  
  17. observe(x()) <- renderUI({
  18.  
  19. dashboardPage(
  20. dashboardHeader(title = "Optimal Overbooking Level..."),
  21. dashboardSidebar(
  22. sidebarMenu(
  23. menuItem("Home"),
  24. menuItem("Inputs", tabName = "inputs"),
  25. menuItem("Outputs", tabName = "op")
  26. )),
  27. dashboardBody(
  28. tabItems(
  29. tabItem(tabName = "inputs",
  30. tabsetPanel(type = "tab",
  31. tabPanel("Scen",
  32. fluidRow(
  33. box( title = "Scen", status = "primary", solidHeader = T,
  34. sliderInput(inputId = "no",label = "Number", value = 100, min =50,max = 300),
  35. sliderInput(inputId = "b",label = "Numbe", value = 20, min = 5,max = 50),
  36. sliderInput(inputId = "atl",label = "Mini", value = 5, min = 1,max = 50),
  37. sliderInput(inputId = "b_ns_start",label = "Minim", value = 20, min = 0,max = 100),
  38. ),
  39. box(title = "Scenario 1", status = "primary", solidHeader = T,
  40. sliderInput(inputId = "ecce",label = "Economy", value = 200, min = 1,max = 5000),
  41. sliderInput(inputId = "ecd",label = "Variation", value = 0, min =0,max = 1000),
  42. sliderInput(inputId = "buprice",label = "Busess", value = 1000, min = 1,max = 10000),
  43. sliderInput(inputId = "busi_sd",label = "Variion", value = 0, min =0,max = 5000),
  44. sliderInput(inputId = "but",label = "Denied", value = 400, min = 1,max = 10000),
  45. sliderInput(inputId = "bu_sd",label = "Variation", value = 0, min =0,max = 5000),
  46. actionButton(inputId = "button", label = "Simulate")
  47. )))
  48. # print("xyz2"),
  49. )),
  50.  
  51.  
  52. # fluidRow(conditionalPanel(condition = "input.button == true"),
  53.  
  54.  
  55. ## Defining Space for output plots
  56. tabItem(tabName = "op",
  57. tabsetPanel(type = "tab",
  58. tabPanel("Scenario 1",
  59. fluidRow(
  60. h3("Profit"),
  61. valueBoxOutput("o"),
  62. valueBoxOutput("eo")
  63. # valueBoxOutput("db"),
  64. # valueBoxOutput("fb")
  65. ),
  66.  
  67. fluidRow(
  68. h3("Cost "),
  69. valueBoxOutput("ne"),
  70. valueBoxOutput("e")
  71. # valueBoxOutput("edb"),
  72. # valueBoxOutput("efb")
  73. ), # print("xyz3"),
  74.  
  75. fluidRow(
  76. box( title = "Invol", status = "primary", solidHeader = T,
  77. plotOutput("Prof"),
  78. plotOutput("Co"),
  79. plotOutput("Emps"),
  80. plotOutput("Upgr")
  81. ),
  82. box( title = "No Upgrades", status = "primary", solidHeader = T,
  83. plotOutput("Eco"),
  84. plotOutput("Ecost"),
  85. plotOutput("Ecots")
  86. ##plotOutput("Eco_Denied_Boarding")
  87. )
  88. ),
  89.  
  90.  
  91. tabItem(tabName = "com",
  92. tabsetPanel(type = "tab",
  93. tabPanel("Scenario - Scenario",
  94. actionButton(inputId = "button3", label = "Compare"),
  95. fluidRow(
  96. box( title = "Involuntary Upgrades", status = "primary", solidHeader = T,
  97. plotlyOutput("Comparofit"),
  98. plotlyOutput("Compat"),
  99. plotlyOutput("Compapty")
  100. ##plotlyOutput("Comparison_DB")
  101. ), # print("xyz5"),
  102.  
  103. box( title = "No Upgrades", status = "primary", solidHeader = T,
  104. plotlyOutput("Coit"),
  105. plotlyOutput("Compt"),
  106. plotlyOutput("Compty")
  107. ##plotlyOutput("CompaDB")
  108. ))),
  109. tabPanel("Within Scenario",
  110. actionButton(inputId = "button4", label = "Compare"),
  111. fluidRow(
  112. box( title = "Scenario 1", status = "primary", solidHeader = T,
  113. plotlyOutput("Compfit1"),
  114. plotlyOutput("Compa1"),
  115. plotlyOutput("Compary1")
  116. ##plotlyOutput("Comparison_DB1")
  117. ),
  118. box( title = "Scenario 2", status = "primary", solidHeader = T,
  119. plotlyOutput("Compit2"),
  120. plotlyOutput("Compat2"),
  121. plotlyOutput("Compar2")
  122. ##plotlyOutput("Comparison_DB2")
  123. )
  124. ))
  125. )))))
  126. # print("xyz6")
  127.  
  128.  
  129. })
  130.  
  131.  
  132. }
  133.  
  134.  
  135. server <- function(input, output,session) {
  136.  
  137.  
  138.  
  139.  
  140. observeEvent(input$load_scenario,{
  141.  
  142. dashboar(reactive(output$input))
  143.  
  144.  
  145. })
  146.  
  147.  
  148. }
  149. shinyApp(ui, server)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement