A paging input for R/Shiny applications
A generic pager widget for R/Shiny based applications.
...
buttons for larger rangespageruiInput()
(for ui.R
) and updatePageruiInput()
(for
server.R
) make it simple to use in any Shiny applicationProvide paging abilities to data sets that require more processing / rendering than a table.
If you don't have the devtools
package, install it:
install.packages('devtools')
This allows you to install packages directly from GitHub. Install this package:
devtools::install_github('wleepang/shiny-pager-ui')
Run the following to see the widget in action:
library(shinyPagerUI)
runExamplePagerUI()
The source for the example application is in:
inst/example_app
global.R
file (create it if it doesn't exist) add the line:library(shinyPagerUI)
ui.R
add the widget as needed using pageruiInput()
.server.R
use updatePageruiInput()
in reactive contexts that need to
update the widget.In ui.R
:
pager
:pageruiInput('pager')
pager
and initial current page of 5, initial total pages 10:pageruiInput('pager', page_current = 5, pages_total = 10)
In server.R
:
pager
pager_state = input$pager
## str(pager_state)
##> List of 2
##> $ page_current: int 1
##> $ pages_total : int 4
pager
updatePageruiInput(session, 'pager', page_current = new_page_current)
pager
updatePageruiInput(session, 'pager', pages_total = new_pages_total)
pager
updatePageruiInput(session, 'pager',
page_current = new_page_current,
pages_total = new_pages_total)