ANALYSIS OF POLLUTION OF TERRASSA (PARE ALEGRE)

Here you can see all the graphics I have created: One of the most important things in this code is to create the "pivotw":

  1. wind2←pivot_wider(wind1,names_from = CODI_VARIABLE, values_from = VALOR_LECTURA)
  2. pivotw←pivot_wider(cityall, names_from = pollutant, values_from = value)
How to create wind2?
  1. wind←read.csv("C://Users/Usuario/Documents/City/wind.csv")
  2. wind1←wind[-c(1,2,5,7,8)]
  3. wind2←pivot_wider(wind1,names_from = CODI_VARIABLE, values_from = VALOR_LECTURA)
  4. names(wind2)[names(wind2) == "31"] ← "wd"
  5. names(wind2)[names(wind2) == "30"] ← "ws"
  6. wind2←replaceall(wind2, c("12:00:00 AM", "01:00:00 AM","02:00:00 AM","03:00:00 AM","04:00:00 AM","05:00:00 AM","06:00:00 AM","07:00:00 AM","08:00:00 AM","09:00:00 AM","10:00:00 AM","11:00:00 AM","12:00:00 PM","01:00:00 PM","02:00:00 PM","03:00:00 PM","04:00:00 PM","05:00:00 PM","06:00:00 PM","07:00:00 PM","08:00:00 PM","09:00:00 PM","10:00:00 PM","11:00:00 PM"), c("00:00:00", "01:00:00", " 02:00:00", " 03:00:00", " 04:00:00"," 05:00:00", " 06:00:00"," 07:00:00", " 08:00:00"," 09:00:00", " 10:00:00"," 11:00:00", " 12:00:00"," 13:00:00", " 14:00:00"," 15:00:00", " 16:00:00"," 17:00:00", " 18:00:00"," 19:00:00", " 20:00:00"," 21:00:00", " 22:00:00"," 23:00:00"))
  7. wind2$date←as.POSIXct(wind2$date,"%d-%m-%Y %H:%M:%S", tz="Europe/Madrid")
  8. cityall←merge(city2, wind2, by ="date")

Figures

timeVariation

> timeVariation(pivotw1, pollutant = c("co","no2","nox","o3","pm10","no","so2"), main="Air pollution in Terrassa (Pare_Alegre) (2019-2022)")

trenLevel

> trendLevel(pivotw1, pollutant = "pm10") > trendLevel(pivotw1, pollutant = "nox") > trendLevel(pivotw1, pollutant = "so2") > trendLevel(pivotw1, pollutant = "no2")

pollutionRose

> pollutionRose(pivotw1, pollutant="no2") > pollutionRose(pivotw1, pollutant="o3") > pollutionRose(pivotw1, pollutant="so2") > pollutionRose(pivotw1, pollutant="pm10")

timePlot

timePlot(pivotw1, pollutant=c("no2","o3","pm10", so2“”))

timePlot(pivotw1, pollutant=c("no2","o3","pm10"))

timePlot(pivotw1, pollutant=c("no2"))

timePlot(pivotw1, pollutant=c("o3"))

timePlot(pivotw1, pollutant=c("pm10"))

calendarPlot

calendarPlot(pivotw1, pollutant="o3", year="2021")

calendarPlot(pivotw1, pollutant="o3", year="2020")

calendarPlot(pivotw1, pollutant="o3", year="2019")

ggplot

ggplot(data=Fig2, aes(x=date, y=value,color=pollutant))+geom_line()+geom_point()+geom_hline(yintercept=40)