| module-sample {datamods} | R Documentation | 
Shiny module to interactively sample a data.frame
Description
Allow to take a sample of data.frame for a given number or proportion of rows to keep.
Usage
sample_ui(id)
sample_server(id, data_r = reactive(NULL))
Arguments
| id | Module id. See  | 
| data_r | 
 | 
Value
- UI: HTML tags that can be included in shiny's UI 
- Server: a - reactivefgunction with the sampled data.
Examples
library(shiny)
library(datamods)
library(reactable)
ui <- fluidPage(
  tags$h2("Sampling"),
  fluidRow(
    column(
      width = 3,
      sample_ui("myID")
    ),
    column(
      width = 9,
      reactableOutput("table")
    )
  )
)
server <- function(input, output, session) {
  result_sample <- sample_server("myID", reactive(iris))
  output$table <- renderReactable({
    table_sample <- reactable(
      data = result_sample(),
      defaultColDef = colDef(
        align = "center"
      ),
      borderless = TRUE,
      highlight = TRUE,
      striped = TRUE
    )
    return(table_sample)
  })
}
if (interactive())
  shinyApp(ui, server)
[Package datamods version 1.5.1 Index]