I'm quite new to R and Shiny so this might be quite basic but I've searched for hours and can't find an answer.
The below (very basic) example renders an editable table and prints out the value of cell [4,1] from the source dataframe below the rendered table. How can I print out the value of cell [4,1] from the editable datatable? (i.e., so that if someone changes the table value, the value printed also changes).
The "Using DT in Shiny" help page states that "after you finish editing [a cell], you can obtain the row/column indices and the new values of the cells that were edited via input$tableId_cell_info
", however I can't find any more info on how to use this feature.
Any help would be much appreciated, thanks!
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(fluidRow(column(offset = 1,
width = 6,
DTOutput('tbl'))),
hr(),
fluidRow(column(offset = 1,
width = 6,
uiOutput('print_cell')))),
server = function(input, output) {
tab <- data.frame(x = c(1,2,3,4),
y = c(5,6,7,8))
output$tbl = renderDT(
datatable(tab,
rownames = FALSE,
editable = TRUE))
output$print_cell <- renderUI(tab[4,1])
}
)```