首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >observeEvent和RHandsontable

observeEvent和RHandsontable
EN

Stack Overflow用户
提问于 2019-03-25 04:07:31
回答 1查看 557关注 0票数 1

我想在shiny中使用RHandsontable执行reactivity,它将从表中获取输入并执行计算。然而,hot_to_r出现了一个错误,但对于我来说,我看不出问题是什么,因为这个问题以前对我很有效。我得到了错误:

代码语言:javascript
复制
Warning: Error in genColHeaders: Change no recognized:afterChange

代码如下:

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2019-03-28 23:42:36

我发现了问题。hot_to_r()必须有dataframe输入,所以下面的代码可以工作

代码语言:javascript
复制
tt <- data.frame('col1' = c(10,30), 'col2' = c(20,40))

hot_to_r(tt)
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55328071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档