The aim of this project is to analysise the datas regarding pollution in Milan from the website of the Comune di Milano. In particular, the study is focused on the different pollutants detected during the years from ARPA stations.
Try the ShinyApp.io: MilanPollution
# first install the R package "devtools" if not installed
devtools::install_github('andreaierardi/MilanPollution')
Load the package.
require(milanpollution)
There are three exported function in the package that are pollution()
and restfullAPI()
.
pollution()
This function loads the Shiny application.
restfullAPI()
Get the dataset from the Opendata website of the city of Milan using CRAN API.
The study consists of 3 dataset named "Rilevazione qualità dell'aria" (Air Quality Detection) from year 2017 to 2019. The dataset is imported from the city of Milan website, in particular the Opendata Portal using CKAN Application programming interface(API).
The datasets has 3 fields:
- Date: date of the detected value
- Pollutant: type of pollutant
- Value: value of the pollutant
- Station_id: ID of the ARPA station.
- Shiny App: interactive web apps
- R language
When launched the pollution() function in the console, the application will start. It takes a bit to load the data from the OpenData Comune di Milano website since the app is using CKAN API. In particular, it checks the years 2017, 2018 and 2019 datasets. After the scraping function downloads the dataset and saved the data in the application memory. In this way, is not necessary to download the data each time we select the year of interest and the general performance are better.
In the main page are presented two plots: the time series representation and the forecast calcolated on the Autoregressive integrated moving average (ARIMA) model.
Using a selector in the left side of the window, is possible to select the year of interest in the dataset. As the application receives the data with the API, the loading of the dataset speed up and there is no much delay changing the year.
In the second page is presented the barplot of the detected data from each station during the years. Using a selector in the left panel of the page, is possible to select the year of interest in which you are interested in displaying how much and which station were active in that year.