如何在R Shiny中实现对数据表的内联编辑

aru*_*daw 16 datatable r shiny

我正在运行一个R Shiny网络应用程序.我使用数据表来显示数据.但我想要内联编辑表格的单元格.我无法做到这一点.任何人都可以指导我吗?

这是我的代码

# UI.R

fluidRow(
         column(4,dataTableOutput("numericalBin")),
         column(8,h1("numericalBin_Chart")))
)
Run Code Online (Sandbox Code Playgroud)
# Server.R

output$numericalBin <- renderDataTable({
    mtcars
  },options = list(    
    lengthChange=FALSE,
    searching=FALSE,
    autoWidth=TRUE,
    paging=FALSE
  ))
Run Code Online (Sandbox Code Playgroud)

我想编辑单元格.以下是我想要发挥作用的链接:https:
//editor.datatables.net/examples/inline-editing/simple.html

我需要在选项列表中添加一些东西,但我找不到合适的.

xcl*_*tet 13

除了@dracodoc提出的DT原型之外,另一种选择是使用rhandsontable包.

编辑:根据@hveig和@Munawir的评论,现在附加了一段工作示例代码(改编自rhandome示例页面):

library(shiny)
library(rhandsontable)

shinyApp(
  shinyUI(
    fluidRow(
      rHandsontableOutput("hot")
    )),

  shinyServer(function(input, output, session) {
    values = reactiveValues()

    data = reactive({
      if (!is.null(input$hot)) {
        DF = hot_to_r(input$hot)
      } else {
        if (is.null(values[["DF"]]))
          DF = mtcars
        else
          DF = values[["DF"]]
      }


      values[["DF"]] = DF
      DF
    })

    output$hot <- renderRHandsontable({
      DF = data()
      if (!is.null(DF))
        rhandsontable(DF, stretchH = "all")
    })
  })
)
Run Code Online (Sandbox Code Playgroud)