Air Cargo Price Estimator

Someshwar Rao S S V
11/27/2017

Delta Air, Domestic Air Freight Standard Cargo Price Estimator

This application estimates Total Freight price in $ for moving air cargo between any two zones within the United States (Zonal Indicators: SE(South East), NE(North East), AK(Alaska), CE(Central), PR, HW(Hawaii) and WE(West).

The price estimation is based on Standard tariff, product code: STD chart with an effective date range of November 1, 2017 - January 31, 2018

Following are the instructions for operating the app:

  • Choose weight of freight in in pounds
  • Choose Origin Zone
  • Choose Destination Zone
  • Click Submit Button

Application

UI Code

library(shiny)

shinyUI(fluidPage(
  span(titlePanel("DELTA AIR, STANDARD AIR CARGO PRICE ESTIMATOR"), style = "color: midnightblue"), br(),
  sidebarLayout(
    sidebarPanel(
      sliderInput(inputId = "Weight", label = "Choose weight in pounds ?",min = 10, max = 1000, value=20),
      selectInput(inputId = "ORG", label = "Choose Origin Zone:",
                  list('South East' = "SE", 'North East' = "NE", 'Central' = "CE", 'West'= "WE", 'Alaska' = "AK", 'Hawaii' = "HW", 'PR' = "PR")
      ),
      selectInput(inputId = "DEST",label =  "Choose Destination Zone:",
                  list('South East' = "SE", 'North East' = "NE", 'Central' = "CE", 'West'= "WE", 'Alaska' = "AK", 'Hawaii' = "HW", 'PR' = "PR")
      ),
      submitButton(text = "Submit Button")
    ),

    mainPanel(
     h4(span(textOutput("results1"),style = "color:navy")),
     h4(span(textOutput("results2"),style = "color: navy")), br(),
     h4(span(textOutput("results3"),style = "color: Blue")), br(),
     h3(span(textOutput("results4"),style = "color: Blue")),
     h5(span(textOutput("results5"),style = "color: red")),
     h5(span(textOutput("results6"),style = "color: green")), br(),
     plotOutput("RatesPlot")
    )

))
)

<!–html_preserve–>

DELTA AIR, STANDARD AIR CARGO PRICE ESTIMATOR





<!–/html_preserve–>

Reactive Code

library(shiny)
library(ggplot2)

shinyServer(function(input, output){
  delta<-read.csv("delta.csv")  
  cnt <<- 19  
  output$results1<-renderText({
    paste("Choosen Weight:",input$Weight," Lb's")
  })
  output$results4<-renderText({
    paste("Variable Price Point (Variable Price Per Pound In $)")
  })
  output$results5<-renderText({
    paste("ORIGIN ZONE: ", input$ORG)
  })
  output$results6<-renderText({
    paste("DESTINATION ZONE: ",input$DEST)
  })
  output$results2<-renderText({
    i = 1
    len = length(delta$ORG)
    for(i in 1:len){
        if((input$ORG == input$DEST)&&(input$ORG == "AK" || input$ORG == "PR" || input$ORG == "HW"))
        {
          res ="No Price Exists For This Route"
          break
        }
        else((delta[i,1] == input$ORG) && (delta[i,2] == input$DEST) )
        {
          minim <- delta[i,3]
          varprice <- delta[i,4]
          res <- minim + varprice*input$Weight
          cnt = i
          break
        }
    }
    paste("Estimated Freight Charges:    $ ",res)
  })

  output$results3<-renderText({
    for(i in 1:length(delta$ORG)){
      if((delta[i,1] == input$ORG) && (delta[i,2] == input$DEST)){
        cnt = i
      }
    }

    paste("Estimated Price = ","(Minimum) $",60," + (Variable Price (Per Pound)) $",delta[cnt,4], " * (Weight)",input$Weight)
  })


  output$RatesPlot <- renderPlot({
    dt<-delta[delta$ORG == input$ORG, c(2,3,4)]
    ggplot(data=dt,aes(DEST,PERLB, width = .5))+geom_bar(stat = "identity", fill = c("dodgerblue4","dodgerblue3","dodgerblue2","dodgerblue1","dodgerblue","deepskyblue1","deepskyblue"))+
      geom_text(aes(label=dt$PERLB, vjust = -1))+ xlab("Destination Zone") + ylab("Price Per Pound")
  })

}

)