1
#Simple UI only contains the modalDialog rendered in server and the simulated selectizeInput to satisfy the condition for modalDialog to display 
ui <- bootstrapPage(uiOutput("new_disease"), selectizeInput("diseases", label = h4("Disease"), 
    choices = list("New", "Not New")))


# Define the server code
server <- function(session, input, output) {
#The code that isn't working run once APPLY is clicked
    observeEvent(input$apply_new, {
        x <- hot_to_r(input$hot)
    })

    output$new_disease <- renderUI({
    #Value of Diseases is reactive to be used in IF statement
        diseases <- reactive({
            input$diseases
        })
        if (!(is.null(diseases()))) {
            x <- diseases()
            #Simulated data
            download_file <- matrix(c("RANDOM DATA", 1, 2, 5, 6, 3), nrow = 3, ncol = 2)

            if (any(x == "New")) {
            #Generates the pop up that houses the editable table
                modalDialog(output$hot <- renderRHandsontable({
                  rhandsontable(download_file, readOnly = FALSE, width = 500, height = 500)
                }), footer = list(actionButton("apply_new", "Apply"), modalButton("Dismiss")))
            }

        }
    })
}

# Return a Shiny app object
shinyApp(ui = ui, server = server) 

此代码的目的是将 rhandsontable 中的编辑值保存在变量“x”中。但是,单击应用按钮后,我收到此错误:

Warning: Error in do.call: second argument must be a list
Stack trace (innermost first):
    67: do.call
    66: hot_to_r
    65: observeEventHandler [C:\Users\robert.derienzo\Desktop\Help_Shiny/app.R#10]
     1: runApp
SEND {"busy":"idle"}

我用谷歌搜索了这个函数的文档数量接近于空。上面的代码将重现我遇到的错误。

4

0 回答 0