File: app.R

package info (click to toggle)
r-cran-dt 0.17%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 848 kB
  • sloc: javascript: 3,687; makefile: 13; sh: 9
file content (31 lines) | stat: -rw-r--r-- 591 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
library(shiny)
library(DT)
shinyApp(
  ui = fluidPage(
    fluidRow(
      column(2, actionButton('refresh', 'Refresh Data', icon = icon('refresh'))),
      column(10, DT::dataTableOutput('foo'))
    )
  ),

  server = function(input, output, session) {

    df = iris
    n = nrow(df)
    df$ID = seq_len(n)

    loopData = reactive({
      input$refresh
      df$ID <<- c(df$ID[n], df$ID[-n])
      df
    })

    output$foo = DT::renderDataTable(isolate(loopData()))

    proxy = dataTableProxy('foo')

    observe({
      replaceData(proxy, loopData(), resetPaging = FALSE)
    })
  }
)