1

I am developing an app where I display a (large) Markov transition matrix as a datatable, rendered client side. Of course, we can make this transition matrix editable for the user.

I would like to be able to:

  • after the user edits some cells and then clicks an update button,
  • to capture all values in all cells of this newly edited datatable (which was edited client side), and return it to R, say, as a matrix

I would then use these values to update a server side matrix/dataframe to now be these new values.

Here is a sample shiny app that might implement this:

library(DT)
library(shiny)


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

    fluidPage(
        textOutput('edit'),
        DTOutput('test'),
        actionButton('actbut', label = 'click')
    )
}

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

    rv <- reactiveValues( df = iris )

    output[['test']] <- renderDT({
        datatable(rv$df, editable = T)
    }, server = F)

    observeEvent(input$actbut, {
        # -- Suppose the user manually changes 
        # --all entries in df in the 
        # --Species column to "setosa", clientside.

        # -- I would like to be able to access the newly changed entries
        # -- using some attribute of input$test_<something>; 
        # -- in the same vein of input$test_cell_clicked, etc.
    })

}

shinyApp(ui = ui, server = server, options = list(port = 5858))

If there is already an easy way to do this, please let me know.

Thanks to Yihui Xie for an incredible library.

Tim Zhou
  • 11
  • 2
  • Found: https://stackoverflow.com/questions/50548785/r-shiny-datatable-with-numericinput-and-reactive-column. It appears that there doesn't seem to be a reliable, stable solution. I have decided to use `rhandsontable` package instead. – Tim Zhou May 04 '19 at 03:30

1 Answers1

0

There does not appear to be a stable/reliable solution, as per: R shiny datatable with numericinput and reactive column

Switching to using package rhandsontable for now. May file this as a feature request on DT github.

Tim Zhou
  • 11
  • 2