如何在dataTable中保存排序? (R语言)

时间:2015-01-15 10:49:18

标签: r datatable frontend shiny

我在页面上有可能在列中排序的表,在我重新加载数据表之后没有再次排序,这里是代码:

    library(shiny)

shinyServer(function(input, output) {

  # Return the requested dataset
  datasetInput <- reactive({
    switch(input$dataset2,
           "[,...]" = diamonds,
           "[10:30,...]" = diamonds,
           "[31:50,...]" = diamonds)
  })

  #"[,...]" = diamonds[,],
  #"[10:30,...]" = diamonds[10:30,],
  #"[31:50,...]" = diamonds[31:50,])

  # Show the first "n" observations
  output$view <- renderTable({
    head(datasetInput())
  })

  # a large table, reative to input$show_vars
  output$mytable1 <- renderDataTable({
    library(ggplot2)
    datasetInput()[, input$show_vars, drop = FALSE]
  }, options = list(stateSave = TRUE))

})

0 个答案:

没有答案