# # This is a Shiny web application. You can run the application by clicking # the 'Run App' button above. # # Find out more about building applications with Shiny here: # # http://shiny.rstudio.com/ # library(shiny) library(ggplot2) # Define UI for random distribution app ---- ui <- fluidPage( sidebarPanel( # Input: Select the random distribution type ---- radioButtons("deck_type", "Deck Type:", c("No Jokers" = "nojoke", "Jokers" = "joke") ), # Normal distribution parameters conditionalPanel( condition = "input.deck_type == 'nojoke'", numericInput("spades", "How many spades?", value = 100), numericInput("clubs", "How many clubs?", value = 100), numericInput("hearts", "How many hearts?", value = 100), numericInput("diamonds", "How many diamonds?", value = 100) ), conditionalPanel( condition = "input.deck_type == 'joke'", numericInput("joke_spades", "How many spades?", value = 100), numericInput("joke_clubs", "How many clubs?", value = 100), numericInput("joke_hearts", "How many hearts?", value = 100), numericInput("joke_diamonds", "How many diamonds?", value = 100), numericInput("joke_jokers", "How many jokers?", value = 2) ) ), mainPanel( # Output: Print the test result ---- verbatimTextOutput("test_result") ) ) # Define server logic required to draw a histogram server <- function(input, output) { output$test_result <- renderPrint({ if (input$deck_type == 'nojoke') { probs <- c(0.25, 0.25, 0.25, 0.25) observed <- c(input$spades, input$clubs, input$hearts, input$diamonds) results <- chisq.test(observed, p = probs) } if (input$deck_type == 'joke') { probs <- c(400/1662, 400/1662, 400/1662, 400/1662, 62/1662) observed <- c(input$joke_spades, input$joke_clubs, input$joke_hearts, input$joke_diamonds, input$joke_jokers) results <- chisq.test(observed, p = probs) } results }) } # Run the application shinyApp(ui = ui, server = server)