соблюдать событие и RHandsontable - PullRequest
0 голосов
/ 24 марта 2019

Я хочу выполнить реактивность с RHandsontable в блестящем, который будет принимать входные данные из таблицы и выполнять расчеты.Однако с hot_to_r происходит ошибка.Но что касается меня, я не вижу, в чем проблема, потому что раньше это работало для меня.Я получаю сообщение об ошибке:

Warning: Error in genColHeaders: Change no recognized:afterChange

Вот код:

library(shinydashboard)
library(rhandsontable)
ui <- dashboardPage(
  dashboardHeader(title = "App"),
  dashboardSidebar(disable = TRUE),
  dashboardBody(skin = "blue",
  box(
    rHandsontableOutput("tt"),
    actionButton(inputId = "sim", label = "Simulate")
  ),
  box(
    tableOutput("result"),
    span(textOutput("error"), style="color:red")
    )
  )
)

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

    tt <- matrix(as.integer(c(10, 20, 30, 40)), nrow = 2, byrow = TRUE)

    output$tt <- renderRHandsontable(rhandsontable(tt, readOnly = FALSE))

    observeEvent( input$sim, {

      tt_input <- hot_to_r(input$tt)

      result <- tryCatch(
       {
        log(tt_input)
       }, warning = function(w){
           return(w$message)
       }, error = function(e){
           return(e$message)
         }
       )

      if(!is(result, "character")){
        output$result <- renderTable(result, rownames = TRUE)
        output$error <- renderText("")
      } else {
        output$error <- renderText({
               result
        })
        output$result <- renderTable(matrix())
      }

    })

}

shinyApp(ui = ui, server = server)

1 Ответ

0 голосов
/ 28 марта 2019

Я обнаружил проблему.У hot_to_r () должен быть ввод данных, поэтому следующее работает

tt <- data.frame('col1' = c(10,30), 'col2' = c(20,40))

hot_to_r(tt)
...