Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从R ShinyTable获取编辑的单元格以更新数据帧_R_Shiny_Reactive Programming_Handsontable - Fatal编程技术网

从R ShinyTable获取编辑的单元格以更新数据帧

从R ShinyTable获取编辑的单元格以更新数据帧,r,shiny,reactive-programming,handsontable,R,Shiny,Reactive Programming,Handsontable,我有一个R数据帧,我正在R ShinyTable中渲染它。ShinyTable中的编辑工作很好 我的问题是:如何接受用户所做的编辑并更新我的数据帧 下面的代码取自ShinyTable的教程网站。它有一个错误:“试图访问不推荐的shinysession$session对象。请直接访问shinysession对象。”但代码中没有引用shinysession的内容 如果我能得到帮助回答我的主要问题(如何接受用户所做的编辑),我就可以绕过这个错误 library(shiny) library(shi

我有一个R数据帧,我正在R ShinyTable中渲染它。ShinyTable中的编辑工作很好

我的问题是:如何接受用户所做的编辑并更新我的数据帧

下面的代码取自ShinyTable的教程网站。它有一个错误:“试图访问不推荐的shinysession$session对象。请直接访问shinysession对象。”但代码中没有引用shinysession的内容

如果我能得到帮助回答我的主要问题(如何接受用户所做的编辑),我就可以绕过这个错误

 library(shiny)
 library(shinyTable)
server <- function(input, output, session) {
  rv <- reactiveValues(cachedTbl = NULL)
  output$tbl <- renderHtable({
    if (is.null(input$tbl)){
      tbl <- matrix(0, nrow=3, ncol=3)
      rv$cachedTbl <<- tbl
      return(tbl)
    } else{
      rv$cachedTbl <<- input$tbl
      return(input$tbl)
    }
  })  

  output$tblNonEdit <- renderTable({
    input$actionButtonID
    isolate({
      rv$cachedTbl
    })
  })    
}
ui <- shinyUI(pageWithSidebar(
  headerPanel("shinyTable with actionButton to apply changes"),
  sidebarPanel(
    helpText(HTML("
                  Make changes to the upper table, press the button to activate. 
                  <p>Created using <a href = \"http://github.com/trestletech/shinyTable\">shinyTable</a>."))),
  mainPanel(
    htable("tbl"),
    actionButton("actionButtonID","apply edits"),
    tableOutput("tblNonEdit")
  )
))

shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(shinyTable)

服务器看起来shinyTable已经有几年没有更新了。会话错误发生在包代码中,而不是您的代码中

请尝试使用rhandsontable

我通过一些示例代码找到了这个问题/答案:

库(闪亮)
图书馆(rhandsontable)
你重铸了吗
library(shiny)
library(rhandsontable)

did_recalc <- FALSE

ui <- fluidPage(
  rHandsontableOutput('table'),
  textOutput('result'),
  actionButton("recalc", "generate new random vals and calculate")
)

server <- function(input,output,session)({
  values <- reactiveValues(data=as.data.frame(runif(2)))

  observe({
    input$recalc
    values$data <- as.data.frame(runif(2))
  })

  observe({
    if(!is.null(input$table))
      values$data <- hot_to_r(input$table)
  })


  output$table <- renderRHandsontable({
    rhandsontable(values$data)
  })


  output$result <- renderText({ 
    sum(values$data)
  })
})  

shinyApp(ui = ui, server = server)