I'm trying to build an app so the user can upload data in the UI, then draw a random sample from it based on a characteristic of the data, then download the sample they made.
Once the data table is uploaded, is it possible for a numeric input to take a sample of it?
So if I upload the location of all of the grocery stores in Nebraska, and want a random sample of 10 from zipcode 68503, would I start by filtering for 68503 then have my (theoretical) sample input then a "generate" button?
The people I'm working with were doing this all back-end in SAS using surveyselect.
I think this project was out of my league....any ideas would be appreciated, informative links are super double appreciated.
This is the only code I have so far. Again, ANY help is appreciated
library(shiny)
library(DT)
Define UI for data upload app ----
ui <- fluidPage(
# App title ----
titlePanel("Project Extra Mile List Generator"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Select a file ----
fileInput("file1", "Choose CSV File",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
# Button
actionButton("update", "Generate",
class = "btn-primary",style='padding:4px; font-size:120%')
),
# Main panel for displaying outputs ----
mainPanel(
# Output: Data file ----
DTOutput("contents")
)
)
)
Define server logic to read selected file ----
server <- function(input, output) {
#Table
output$contents <- renderDT({
req(input$file1)
df <- read.csv(input$file1$datapath)
})
}
Create Shiny app ----
shinyApp(ui, server)