#importing the needed libraries library(readr) library(ggplot2) library(lubridate) #library(data.table) library(openair) library(dplyr) #library(zoo) #library(rio) library(tidyverse) #========================IMPORTING THE DATA ============================= #======DATA PATH ================================================= data_gh <- 'C:/Users/USER/OneDrive/Documents/WORKSHOPS_SCHOOLS/SUMMER_SCHOOL_2025/PRACTICAL/R_CODES/cleaned_met_aq_data2.csv' data_uk <- 'C:/Users/USER/OneDrive/Documents/WORKSHOPS_SCHOOLS/SUMMER_SCHOOL_2025/PRACTICAL/R_CODES/ukaqdata2.csv' #mary <- importAURN(site = "my1", year = 1990:2010) df <- import(data_gh,header=TRUE,sep = ',', date = 'Time', date.format = '%Y-%m-%d %H:%M', na.strings = c("-99.0", "-999","-9999","")) df2 <- import(data_uk,header=TRUE,sep = ',', date = 'Time', date.format = '%Y-%m-%d %H:%M%:%S', na.strings = c("-99.0", "-999","-9999","")) df2$date <- ymd_hms(df2$date) df$date_time <- lubridate::mdy_hm(df$date_time) #renaming some columns df<- rename(df,date = date_time,pm25 = 'PM2.5_ug/m3',pm10='PM10_ug/m3', temp=obs_temp,rh=obs_RH,temp2=sensor_temp,rh2=sensor_RH, ws=obs_wind_speed,wd2=wd,wd=wind_direc,ws2=windspeed) #viewing some stats and details of the data summaryPlot(df,avg.time = 'day') summaryPlot(df2,avg.time = 'day') #time variation plot timeVariation(df, pollutant = c("pm25", "pm10"), normalise = FALSE) timeVariation(df2, pollutant = c("pm2.5", "pm10"), normalise = FALSE) #timeplot timePlot(head(df, 48), pollutant = c("pm25", "pm10"), windflow = list(scale = 0.1, lwd = 2, col = "black"), lwd = 3, group = FALSE, ylab = "concentration (ug/m3)") timePlot(df2, pollutant = c("nox", "o3","air_temp","pm2.5"),y.relation = "free", avg.time = "day") #calender plot calendarPlot(df, pollutant = "pm25", year =2020) calendarPlot(df2, pollutant = "pm2.5", year = 2019, annotate = "wd") calendarPlot(df2, pollutant = "pm2.5", year = 2020, breaks = c(0, 14, 50, 100, 150, 300), labels = c("Low", "Moderate", "High", "Very High","Severe"), cols = c("forestgreen", "yellow","orange", "red", "purple"), statistic = "max") #windrose plots and pollution rose windRose(df,ws='ws',wd='wd', type = "month", layout = c(6, 2)) windRose(df2, type = "pm2.5") pollutionRose(df, pollutant = "pm25") pollutionRose(df2, pollutant = "pm2.5",type='month') polarPlot(df,pollutant = "pm25",x = "ws",wd = "wd") polarPlot(df2,pollutant = "pm2.5",x = "ws",wd = "wd") polarFreq(df, type = "month") polarFreq(df2, pollutant = "pm2.5", type='month',ws.int = 30, statistic = "weighted.mean", offset = 80, trans = FALSE, col = "heat") trendLevel(df, x = "season", y = "daylight", pollutant = "pm25") trendLevel(df2, x = "season", y = "daylight", pollutant = "pm2.5") trendLevel(df2, x = "season", y = "hour", pollutant = "pm2.5", cols = "increment") polarAnnulus(df2, poll = "o3",period = "weekday", main = "weekday") polarAnnulus(df, poll = "pm25",period = "season", main = "season")