Presentation Peer-graded Assignment Course Project Shiny Application and Reproducible Pitch

author: Auke Beeksma date: 14-2-2019, loveday autosize: true

Coursera

The Shiny application in question is entirely up to you. However, if you’re having trouble coming up with ideas, you could start from the simple prediction algorithm done in class and build a new algorithm on one of the R datasets packages. Please make the package simple for the end user, so that they don’t need a lot of your prerequisite knowledge to evaluate your application. You should emphasize a simple project given the short time frame.

Ui data

setwd("C:/users/auke.beeksma/Desktop/Developing dataproducts in R/Courseproject Shiny app and presentation/Courseproject")
library(dplyr)
library(ggplot2)
library(readr)
library(shiny)
bcl <- read.csv("bcl-data.csv", stringsAsFactors = FALSE)

products <- c("BEER", "REFRESHMENT BEVERAGE", "SPIRITS", "WINE")
bcl <- dplyr::filter(bcl, PRODUCT_CLASS_NAME %in% products) %>%
  dplyr::select(-PRODUCT_TYPE_NAME, -PRODUCT_SKU_NO, -PRODUCT_BASE_UPC_NO,
                -PRODUCT_LITRES_PER_CONTAINER, -PRD_CONTAINER_PER_SELL_UNIT,
                -PRODUCT_SUB_CLASS_NAME) %>%
  rename(Type = PRODUCT_CLASS_NAME,
         Subtype = PRODUCT_MINOR_CLASS_NAME,
         Name = PRODUCT_LONG_NAME,
         Country = PRODUCT_COUNTRY_ORIGIN_NAME,
         Alcohol_Content = PRODUCT_ALCOHOL_PERCENT,
         Price = CURRENT_DISPLAY_PRICE,
         Sweetness = SWEETNESS_CODE)
bcl$Type <- sub("^REFRESHMENT BEVERAGE$", "REFRESHMENT", bcl$Type)

shinyUI(fluidPage(
  titlePanel("My app for Coursera"),
  h4("BC Liquor Store prices", style = "color: blue;"),
  " Using the BC Liquor data",
  br(),
  br(),
  br(),
  strong("Store", "prices"),
  strong(div("Alcoholic producttypes", style = "color: red;")),
  strong(div(em("Countries", style = "color: purple;"))),
  
  sidebarLayout(
    sidebarPanel(
      sliderInput("priceInput", "Price", min = 0, max = 100, value = c(0, 100), pre = "$"),
      radioButtons("typeInput", "Product type",
                   choices = c("BEER", "REFRESHMENT", "SPIRITS", "WINE"),
                   selected = "WINE"),
      uiOutput("countryOutput")
    ),
    mainPanel(
      plotOutput("coolplot"),
      br(), br(),
      tableOutput("results")
      
  )
)
))

My app for Coursera

BC Liquor Store prices

Using the BC Liquor data


Store prices
Alcoholic producttypes
Countries


Server data ========================================================

server <- function(input, output) {
  filtered <- reactive({
    if (is.null(input$countryInput)) {
      return(NULL)
    }  
    bcl %>%
      filter(Price >= input$priceInput[1],
             Price <= input$priceInput[2],
             Type == input$typeInput,
             Country == input$countryInput
      )
  })
  
  output$coolplot <- renderPlot({
    if (is.null(filtered())) {
      return()
    }
    
    ggplot(filtered(), aes(Alcohol_Content)) +
      geom_histogram(fill = "blue") + 
      theme(plot.background = element_rect(color = "yellow", fill = "pink", size = 6)) 
  })
  
  output$countryOutput <- renderUI({
    selectInput("countryInput", "Country",
                sort(unique(bcl$Country)),
                selected = "AUSTRALIA")
  })
  
  output$results <- renderTable({
    filtered()
  })
}

The fifth page

I wish you a good day!