Создание панели с помощью вызова функции - PullRequest
0 голосов
/ 16 мая 2019

Я пытаюсь поставить панель управления внутри кнопки действия с помощью вызова функции.Вот мой пример кода

library(shiny)
library(pool)
 library(shinydashboard)

  ui <- fluidPage(


   actionButton("load_scenario","load scenario"),
  uiOutput("input")

 )


    dashboar <- function(x){


  observe(x()) <- renderUI({

dashboardPage(
  dashboardHeader(title = "Optimal Overbooking Level..."),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Home"),
      menuItem("Inputs", tabName = "inputs"),
      menuItem("Outputs", tabName = "op")
    )),
  dashboardBody(
    tabItems(
      tabItem(tabName = "inputs",
              tabsetPanel(type = "tab",
                          tabPanel("Scen",
                                   fluidRow(
                                     box( title = "Scen", status = "primary", solidHeader = T,
                                          sliderInput(inputId = "no",label = "Number", value = 100, min =50,max = 300),
                                          sliderInput(inputId = "b",label = "Numbe", value = 20, min = 5,max = 50),
                                          sliderInput(inputId = "atl",label = "Mini", value = 5, min = 1,max = 50),
                                          sliderInput(inputId = "b_ns_start",label = "Minim", value = 20, min = 0,max = 100),
                                         ),
                                     box(title = "Scenario 1", status = "primary", solidHeader = T,
                                         sliderInput(inputId = "ecce",label = "Economy", value = 200, min = 1,max = 5000),
                                         sliderInput(inputId = "ecd",label = "Variation", value = 0, min =0,max = 1000),
                                         sliderInput(inputId = "buprice",label = "Busess", value = 1000, min = 1,max = 10000),
                                         sliderInput(inputId = "busi_sd",label = "Variion", value = 0, min =0,max = 5000),
                                         sliderInput(inputId = "but",label = "Denied", value = 400, min = 1,max = 10000),
                                         sliderInput(inputId = "bu_sd",label = "Variation", value = 0, min =0,max = 5000),
                                          actionButton(inputId = "button", label = "Simulate")
                                     )))
                          #    print("xyz2"),
              )),


      # fluidRow(conditionalPanel(condition = "input.button == true"),


      ## Defining Space for output plots
      tabItem(tabName = "op",
              tabsetPanel(type = "tab",
                          tabPanel("Scenario 1",
                                   fluidRow(
                                     h3("Profit"),
                                     valueBoxOutput("o"),
                                     valueBoxOutput("eo")
                                     # valueBoxOutput("db"),
                                     # valueBoxOutput("fb")
                                   ),                                

                                   fluidRow(
                                     h3("Cost "),
                                     valueBoxOutput("ne"),
                                     valueBoxOutput("e")
                                     # valueBoxOutput("edb"),
                                     # valueBoxOutput("efb")
                                   ),                #                print("xyz3"),

                                   fluidRow(
                                     box( title = "Invol", status = "primary", solidHeader = T,
                                          plotOutput("Prof"),
                                          plotOutput("Co"),
                                          plotOutput("Emps"),
                                          plotOutput("Upgr")
                                     ),
                                     box( title = "No Upgrades", status = "primary", solidHeader = T,
                                          plotOutput("Eco"),
                                          plotOutput("Ecost"),
                                          plotOutput("Ecots")
                                          ##plotOutput("Eco_Denied_Boarding")
                                     )
                                   ),


      tabItem(tabName = "com",
              tabsetPanel(type = "tab",
                          tabPanel("Scenario - Scenario",
                                   actionButton(inputId = "button3", label = "Compare"),
                                   fluidRow(
                                     box( title = "Involuntary Upgrades", status = "primary", solidHeader = T,
                                          plotlyOutput("Comparofit"),
                                          plotlyOutput("Compat"),
                                          plotlyOutput("Compapty")
                                          ##plotlyOutput("Comparison_DB")
                                     ),                     #           print("xyz5"),

                                     box( title = "No Upgrades", status = "primary", solidHeader = T,
                                          plotlyOutput("Coit"),
                                          plotlyOutput("Compt"),
                                          plotlyOutput("Compty")
                                          ##plotlyOutput("CompaDB")
                                     ))),
                          tabPanel("Within Scenario", 
                                   actionButton(inputId = "button4", label = "Compare"),
                                   fluidRow(
                                     box( title = "Scenario 1", status = "primary", solidHeader = T,
                                          plotlyOutput("Compfit1"),
                                          plotlyOutput("Compa1"),
                                          plotlyOutput("Compary1")
                                          ##plotlyOutput("Comparison_DB1")
                                     ),
                                     box( title = "Scenario 2", status = "primary", solidHeader = T,
                                          plotlyOutput("Compit2"),
                                          plotlyOutput("Compat2"),
                                          plotlyOutput("Compar2")
                                          ##plotlyOutput("Comparison_DB2")
                                     )
                                   ))
                 )))))
#  print("xyz6")


   })


}


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




  observeEvent(input$load_scenario,{

  dashboar(reactive(output$input))


   })


}
shinyApp(ui, server)

Здесь моя задача состоит в том, чтобы вызвать функцию, и функция не должна присутствовать внутри серверной функции. При выполнении кода выше я получаю следующую ошибку

Ошибка в <-: неверная (NULL) левая сторона назначения <br>[трассировка стека недоступна]

...