This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
#install.packages("openair") #this installs the necessary package used for the actual data analysis done here (NB: for the html file submission, line 19 is commented out, otherwise the knit function would not work)
library(openair) #this loads the package into the R's memory which increases efficieny
## Warning: package 'openair' was built under R version 3.4.4
importMeta() #this imports the relevant air data into R
air_data <- importAURN(site = "NPT3", year = 2009:2018) #creates a useable data frame for this project and assigns it the correct data from the chosen site
## Warning: You have selected some data that is less than 6-months old.
## This most recent data is not yet ratified and may be changed
## during the QA/QC process. For complete information about the
## ratification status of a data set, please use the online tool at:
## http://www.airquality.co.uk/data_and_statistics.php?action=da_1&go=Go
timePlot(air_data, pollutant = c("no","no2"), group = FALSE, avg.time = "year", name.pol = c("NO","NO2"), ylab = "Pollutant concentration (µg / m3)", xlab = "Year") #using openair's built in time plot command, the specific pollutants are selected and then assigned yearly average intervals for the figure output
timeVariation(air_data, pollutant = c("no","no2"), name.pol = c("NO","NO2"), ylab = "(µg / m3)") #openair's built in timeVariation function, with selected pollutants, produces this figure with the various temporal average graphs
median(air_data$no, na.rm=T) #simple math command that calculates the median value from the entire data set, inside the brackets is where the pollutant is selected and the N/A values in the data are removed
## [1] 3.8657
max(air_data$no, na.rm=T) #max, min and mean all follow the same process as the comment above
## [1] 360
min(air_data$no, na.rm=T)
## [1] 0
mean(air_data$no, na.rm=T)
## [1] 10.85038
median(air_data$no2, na.rm=T) #same mathematical data summaries, but this time NO2 is the selected pollutant
## [1] 17.216
max(air_data$no2, na.rm=T)
## [1] 256
min(air_data$no2, na.rm=T)
## [1] -0.47095
mean(air_data$no2, na.rm=T)
## [1] 22.3328
scatterPlot(air_data, x = "no", y = "no2", linear=T, name.pol = c("NO","NO2"), ylab = "NO2 (µg / m3)", xlab = "NO (µg / m3)") #openair's scatterPlot feature will plot all data points for the combined selected pollutants, and then using "linear=T" we can invoke the command to add a line of best fit to the graph as well