module-sample | R Documentation |
data.frame
Allow to take a sample of data.frame
for a given number or proportion of rows to keep.
sample_ui(id)
sample_server(id, data_r = reactive(NULL))
id |
Module id. See |
data_r |
|
UI: HTML tags that can be included in shiny's UI
Server: a reactive
fgunction with the sampled data.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.