I have an application for building real-time data visualization with the R shiny
library. I periodically reload data from a file using the reactivePoll
function. What I don't like is that whenever the data is reloaded, the whole application is updated.
So, if I have DT
table output with a selection, and I use this input$table_rows_selected
, it is reset to NULL
whenever information that is not user friendly is reloaded.
Is it possible to change the output at all without interrupting the user?
UPDATE
Can this be done with any other package for displaying tables - googleVis
or another?
Working example.
library(shiny) library(DT) runApp(shinyApp( ui = fluidPage(dataTableOutput('table')), server = function(input, output, session) { pollData <- reactivePoll(4000, session, checkFunc = function(){ Sys.time() }, valueFunc = function(){ data.frame(id = sample(letters[1:3]), a = runif(3), b = runif(3), c = runif(3)) }) output$table <- renderDataTable({pollData()}) proxy <- dataTableProxy('table') observeEvent(pollData(), { selectRows(proxy, input$table_rows_selected) })} ))
I took this example from @NicE's answer and added the id column. The fact is that @NicE's answer is fine if you need to select a specific line when this line is identified by the line number.
Now suppose I need a string to select when this string is identified by some id value. That is, if I select a row with id equal to b, then the next time I reload the data, I want the row to be selected with the same id value.
source share