Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

r dataTable save as RDS rather than jso

$
0
0

I'm trying to follow this example from the dataTable github which (as I understand it) saves a user edited dataTable to the server. However, I would like it to save as an RDS instead of a JSON file.

The DT example code:

library(shiny)
library(DT)
shinyApp(
  ui = fluidPage(
    DTOutput('x1')
  ),
  server = function(input, output, session) {
    x = iris
    x$Date = Sys.time() + seq_len(nrow(x))
    output$x1 = renderDT(x, selection = 'none', editable = TRUE)

    proxy = dataTableProxy('x1')

    observeEvent(input$x1_cell_edit, {
      info = input$x1_cell_edit
      str(info)
      i = info$row
      j = info$col
      v = info$value
      x[i, j] <<- DT::coerceValue(v, x[i, j])
      replaceData(proxy, x, resetPaging = FALSE)  # important
    })
  }
)

I can read in my own RDS fine, and dataTable appears to edit it fine, but I can't figure out how to save the edits back to the original RDS. Any ideas?

A bit of background. I am trying to set up a settings file for my shiny app. I want the same settings to be persistent and to apply to all users (both of them) and for either user to be able to edit the settings file. Having an editable datatable appears to me to be the most obvious way to do it, but I'm open to other ideas.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>