knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This vignette outlines some core functionality in {openair}. For further examples, please see the online book.

library(openair)

Import data from the UK Automatic Urban and Rural Network

It is easy to import hourly data from 100s of sites and to import several sites at one time and several years of data.

kc1 <- importAURN(site = "kc1", year = 2020)
kc1

Utility functions

Using the selectByDate() function it is easy to select quite complex time-based periods. For example, to select weekday (Monday to Friday) data from June to September for 2012 and for the hours 7am to 7pm inclusive:

sub <- selectByDate(
  kc1,
  day = "weekday",
  year = 2020,
  month = 6:9,
  hour = 7:19
)
sub

Similarly it is easy to time-average data in many flexible ways. For example, 2-week means can be calculated as

sub2 <- timeAverage(kc1, avg.time = "2 week")
sub2

The type option

One of the key aspects of openair is the use of the type option, which is available for almost all {openair} functions. The type option partitions data by different categories of variable. There are many built-in options that type can take based on splitting your data by different date values. A summary of in-built values of type are:

type can also use variables already in the data frame:

Example directional analysis

{openair} can plot basic wind roses very easily provided the variables ws (wind speed) and wd (wind direction) are available.

windRose(mydata)

However, the real flexibility comes from being able to use the type option.

windRose(mydata,
  type = "year",
  layout = c(4, 2)
)

Wind roses summarising the wind conditions at a monitoring station per year, demonstrating the {openair} type option.

There are many flavours of bivariate polar plots, as described here that are useful for understanding air pollution sources.

polarPlot(mydata,
  pollutant = "so2",
  statistic = "cpf",
  percentile = 90,
  cols = "YlGnBu"
)


davidcarslaw/openair documentation built on Oct. 10, 2024, 12:32 p.m.