Air Quality VS Respiratory Diseases Dashboard: Shiny as a Powerful Tool for Data-Driven Insights
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Understanding the Air Pollution with Shiny
Air pollution is a global problem that affects the health and well-being of millions of people each year. Poor air quality is linked to various respiratory diseases such as asthma, chronic obstructive pulmonary disease (COPD), and lung cancer. Monitoring air quality is crucial in comprehending its impact on public health and implementing necessary measures to mitigate its adverse effects.
In this blog post, we will discuss the Air Quality VS Respiratory Diseases Shiny dashboard, using it as a showcase for how organizations can use dashboards to interpret results, engage stakeholders, and incite change.
The Power of Data Visualization
The fundamental idea behind this dashboard is to merge data on air pollutants and respiratory diseases to identify connections between air quality and respiratory illnesses. To achieve this, visualizing the data in a relatable manner can have a significant impact in effectively conveying the story derived from the dataset.
Data can have a real, positive impact on the world. See how Appsilon leverages Data Science for Good.
Data visualization serves as a powerful tool that enables organizations to comprehend intricate datasets and make informed decisions. The Air Quality VS Respiratory Diseases Dashboard employs interactive data visualization techniques to present information on air quality and respiratory diseases in a user-friendly format. Users have the ability to explore the data, uncover trends, and identify patterns that can contribute to decision-making processes.
Tech, Data Sources and Management
What We Used
The dashboard was created using R Shiny with the assistance of the {rhino} framework. Through the power of visualizations, including maps, charts, and graphs, it aids users in understanding the data.
What It Does
Upon opening the application, users are greeted with a map of Europe featuring scattered dots colored from light red to dark red. These colors represent the air quality index (AQI), where higher values indicate greater levels of air pollution and increased health concerns. Gray dots indicate areas where air pollutant data was unavailable due to various reasons, such as monitoring stations not being set up yet, while data for respiratory diseases were still accessible.
Data Sources
There are two data sources utilized in this application. The European Environment Agency (EEA) supplies the data on air pollutants and air quality, while the {eurostat} R package furnishes data on demographic and other indicators pertaining to prevalent respiratory diseases in European countries.
Data In Action
The application ingests live data from the European Environment Agency (EEA), and in cases where the API is unavailable, the app gracefully handles the situation by resorting to static cached data. The static cached data is regularly updated on a weekly basis for the EEA data and daily for the {eurostat} data through the use of cronjobs executed as GitHub Actions.
These automated processes download data from the APIs and write it to a PositConnect instance using the {pins} package. These backups are solely accessed if the live data API fails to provide the required information. Additionally, apart from the static data residing in the PositConnect instance, each R process serving a user caches the data locally in memory using the {memoise} package. This ensures that previously served requests can be delivered instantly.
Innovative Data Visualization Techniques with Shiny
As is common in some R Shiny applications with maps, the {leaflet} package is employed to provide the map view. A seemingly small, but unique change is the use of flower icons within each marker’s popup, representing the proportions of air pollutants recorded at specific monitoring stations.
Why a flower? While simple bar charts can directly convey exact values, we aimed to raise awareness and engage users through an innovative approach. In this representation, the length of each petal symbolizes the amount of a particular pollutant detected at the station. By using a large flower, we can capture a user’s attention and foster increased engagement with the dashboard.
From a technical standpoint, this visualization was generated using D3.js, a JavaScript library renowned for its capability in creating custom, creative data visualizations. R Shiny enables the incorporation of expertise from JavaScript developers within a team, allowing for the creation of stunning graphics using D3.js, even within an R Shiny framework. While it is possible to create D3.js plots using the {r2d3} package, in this case, since we are injecting the plot into a leaflet popup, we opted to use plain JavaScript for this task.
One technical challenge we encountered was transferring data from the generated leaflet popup to the D3 plot. We successfully overcame this obstacle by passing the data as an HTML attribute to the leaflet popup, which is then detected by a MutationObserver in JavaScript, monitoring the leaflet popup pane for the addition of new popups.
Insightful Representations
Upon clicking on a monitoring station, the panel below the map dynamically updates to display the name of the country where the station is located, along with information regarding the prevalent respiratory diseases in that country. Here also, the approach has been to create an impact by engaging users with captivating insights.
Firstly, a population pyramid is utilized to showcase the distribution of deaths from respiratory diseases based on age and gender, providing viewers with valuable information for those considering relocating to areas with varying air pollutants. Additionally, rows of candles appear alongside the population pyramid, representing the Years of Life Lost (YLL) due to mortality. Each YLL signifies the loss of one year of life and is calculated by multiplying the number of deaths by a global standard life expectancy at the age of death.
Ready to try out R Shiny? Download our free templates to hit the ground running!
This approach considers the impact of premature mortality by incorporating both the frequency of deaths and the age at which they occur. While a single YLL value represents a specific country, conveying its gravity solely as a number may not effectively communicate its significance.
To address this, the concept of birthday wishes lost is introduced, symbolized by the candles. As birthdays are highly anticipated occasions, showcasing the candles represents the unrealized potential of lives lost due to air pollution. Each candle represents 365 years of lives lost, illustrating the profound impact and emphasizing the missed opportunities for celebration and growth.
This poignant visualization underscores the urgent need for improved air quality to prevent such premature deaths.
Impact and Potential Applications for Shiny
The potential benefits of this project extend far beyond its immediate scope, offering valuable insights to a diverse range of organizations.
Public health agencies can leverage this dashboard as a powerful tool for monitoring air quality and respiratory disease rates within their communities. By identifying areas of concern, they can effectively target their efforts and interventions where they are most needed.
R Shiny is making fast strides in Government and Non-Government Organizations. See the power of R Shiny in Government with real examples.
Similarly, environmental organizations can utilize the dashboard to advocate for policies and initiatives that enhance air quality, while policymakers can make more informed decisions regarding air quality regulations and public health measures.
Conclusion: Finding Breathing Room with Shiny
The Air Quality VS Respiratory Diseases Dashboard serves as a robust tool that empowers organizations to make data-driven decisions to improve air quality and public health. By integrating data on air quality and respiratory diseases and presenting it in a user-friendly format, the dashboard enables users to explore the data, identify trends, and gain valuable insights for decision-making processes. Its showcase of flexibility, scalability, and ease of use make it a beneficial resource for influencing various organizations, ranging from public health agencies to policymakers.
If you want to learn more about how Shiny can impact your data and unlock valuable insights, reach out to us today or explore our collection of Shiny demos. Our team of experts is ready to assist you in leveraging the power of data visualization and analysis for your organization’s success.
The post appeared first on appsilon.com/blog/.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.