2024-01-24

Overview

This application is developed using Shiny and is hosted on Shinyapps.io

I have used the Virginia Death Rate Dataset from R datasets for creating this application.

This app showcases the Death rates per 1000 in Virginia in 1940 amongst different age groups : 50–54, 55–59, 60–64, 65–69, 70–74 for the population groups: Rural/Male, Rural/Female, Urban/Male and Urban/Female.

Dataset

The dataset can be viewed as below:

##       Rural Male Rural Female Urban Male Urban Female
## 50-54       11.7          8.7       15.4          8.4
## 55-59       18.1         11.7       24.3         13.6
## 60-64       26.9         20.3       37.0         19.3
## 65-69       41.0         30.9       54.6         35.1
## 70-74       66.0         54.3       71.1         50.0

Shiny UI

library(plotly)
library(shiny)

shinyUI(fluidPage(
  titlePanel("Virginia Death Rate App"),
  sidebarLayout(
    sidebarPanel(
      h1("Choose a Category"),
      selectInput("select1", "Select", choices = c("Rural Male", "Rural Female", "Urban Male","Urban Female")),
    ),
    mainPanel(
      plotlyOutput("plot1"),
      
    )
  )
))

Virginia Death Rate App

Choose a Category

Shiny Server

library(shiny)
library(plotly)
shinyServer(function(input,output){
  output$plot1 <- renderPlotly({
  my_data <- data.frame("Age"=rownames(VADeaths), VADeaths)
  cate <- input$select1
  print(cate)
  if(cate == "Rural Male"){
    plot_ly(my_data,x = ~Age,  y= my_data$Rural.Male,type = 'bar',name = "Rural Male")
    }
  else if(cate == "Rural Female"){
    plot_ly(my_data,x = ~Age,  y= my_data$Rural.Female,type = 'bar',name = "Rural Female")
  }
  else if(cate == "Urban Male"){
  plot_ly(my_data,x = ~Age,  y= my_data$Urban.Male,type = 'bar',name = "Urban Male")
  }
  else{
  plot_ly(my_data,x = ~Age,  y= my_data$Urban.Female,type = 'bar',name = "Urban Female")
    }
  })
})

Output

The output is a shiny app which displays the deaths per age group for different population groups, visually presented as a bar graph.

The application can be viewed at https://shams10.shinyapps.io/virginiadeathrates/

Use can select a category of the population and can view the death distribution adjacdent to it. THe bar graph cahnges values dynamically.

Thanks!