Hi, I developed a shiny application to randomly select a single output on-click of the action button. How do I display the result as a modal pop-up? See my code below
library(styler)
library(shiny)
library(shinythemes)
library(shinydashboard)
library(tidyverse)
library(DT)
library(dplyr)
library(shinyBS)
#library(dt)
ui<-fluidPage(
dashboardPage(skin="black",
dashboardHeader(title=tags$em("Aura Promo", style="text-align:center;color:#ff8300;font-size:100%"),titleWidth = 800),
dashboardSidebar(width = 270,
sidebarMenu(
#br(),
menuItem(tags$em("Upload Data",style="font-size:120%"),icon=icon("upload"),tabName="data"),
fileInput('datafile', 'Upload',
accept=c('csv', 'comma-separated-values','.csv')),
actionButton("update", "Select Winner", icon = icon("table"),
class = "btn-default",style='padding:4px;font-size:100%')
)
),
dashboardBody(
tabItems(
tabItem(tabName="data",
fluidRow(
# valueBoxOutput("Total"),
#valueBoxOutput("Gross"),
#valueBoxOutput("NoBypass")
),
br(),
br(),
br(),
column(width = 4,
tableOutput('table'),
br(),
br(),
br(),
),
# Output: Data file ----
tableOutput("contents") #DTOutput("contents")
)))))
server <- function(input, output,session) {
dataframe<-reactive({
if (is.null(input$datafile))
return(NULL)
data<-read.csv(input$datafile$datapath)
data
})
#Generate random values
observeEvent(input$update, {
sampled_df <- reactive({
test <- dataframe()[sample(nrow(dataframe()), 1), ]
test
})
#Display Table on click
output$table <- renderTable({
sampled_df()
})
})
# Display random output
output$contents <- renderTable({
dataframe()
})
}
## Run the application
shinyApp(ui = ui, server = server)