3 December 2017

Singapore Rainfall Visualization

This is a interactive visualization of the rainfall data in Singapore from January 1982 to October 2017. The application was built with the shiny r package and is available at https://kctoh.shinyapps.io/ShinyTest/

Application

  • Users can select year from the slider and load required data
  • The selected data will be visualized in a bar plot and a table.
  • The bar plot will show the distribution of rainfall by months.
  • Sample Code
shinyServer(function(input, output) {
  selecteddata<- reactive({
    subset(data,subset=(substring(data$Year,1,4)==input$Year))
  })
  output$barPlot <- renderPlot({
    plotdata<-selecteddata()
    barplot(plotdata$total_rainfall,names.arg=plotdata$month,
            xlab="Month", ylab="Rainfall",col="lightblue")
  })
  output$table <- renderTable({
    selecteddata()
  })

Data

Data is downloaded from Data SG Headers in the data set are:

  • month
  • Year
  • total rainfall
##      month          Year      total_rainfall  
##  Apr    : 36   Min.   :1982   Min.   :  0.20  
##  Aug    : 36   1st Qu.:1990   1st Qu.: 94.05  
##  Feb    : 36   Median :1999   Median :159.45  
##  Jan    : 36   Mean   :1999   Mean   :178.53  
##  Jul    : 36   3rd Qu.:2008   3rd Qu.:239.95  
##  Jun    : 36   Max.   :2017   Max.   :765.90  
##  (Other):214

Thank you