
Import Monthly and Annual Summaries of UK Air Quality Data
Source:R/import_ukaq_summaries.R
import_ukaq_summaries.RdImports either annual or monthly summaries matching UK AIR. Unlike the data
available in import_ukaq_measurements(), this data is appended with a
monthly/annual data capture and additional relevant columns (e.g., the month
as a character for monthly data).
Usage
import_ukaq_summaries(
code = NULL,
year,
source = "aurn",
data_type = "annual",
pollutant = NULL,
append_metadata = FALSE,
metadata_columns = c("site_type", "latitude", "longitude"),
pivot = "wide",
progress = NA,
...,
.class = NULL
)Arguments
- code
Specific site codes to import.
default:
NULLcodeexpects a vector of character values. It defines the specific sites to import will filter the result for specific sites based on their site codes, available throughimport_ukaq_meta(). Note that a mismatch betweencodeandsourcemay result in no data being imported. IfNULL, the default, all available data for theyearandsourcewill be returned.- year
A year, or range of years, from which to import data.
required
yearexpects a vector of integer values. It can be a single year (2020), a selection of specific years (c(2020, 2021, 2022)), or a range of years (2020:2025).- source
One or more UK Monitoring networks from which to import data.
default:
"ukaq"The default,
"ukaq", will look for sites from any of the available networks. Any combination of"aurn","aqe","saqn","waqn","niaqn"or"lmam"will only import data from those specific monitoring networks. Note that a mismatch betweencodeandsourcemay result in no data being imported.- data_type
What type of summary should be returned?
default:
"annual"import_ukaq_summaries()can return either"annual"(the default) or"monthly"summary data.- pollutant
One or more pollutants for which to import data.
default:
NULLBy default, all available pollutants are imported.
pollutantallows any specific combination of the pollutants to be returned instead.- append_metadata
Append site metadata to the dataframe?
default:
FALSEWhen
TRUE, the resultingdata.framewill have site metadata appended. The specific columns are selected usingmetadata_columns.- metadata_columns
Specific metadata columns to append to the data.frame.
default:
c("site_type", "latitude", "longitude")When
append_metadata = TRUE, the columns selected here will be appended to the data. Columns names should match those inimport_ukaq_meta(), excluding pollutant-specific columns (e.g., ratification date).- pivot
Should the dataframe be 'wide' or 'long'?
default:
"wide"There are two main ways to store air quality data; "long" (with 'pollutant' and 'value' columns) or "wide" (with each pollutant value being stored in its own column).
pivotallows users to define which format they would prefer their data in.- progress
Show a progress bar?
default:
NAWhen
TRUE, this function will print a progress bar to track individual files being imported. IfFALSEthis is suppressed. IfNA, the default, the function will work out if a progress bar would be useful (i.e., if the function is being run in an interactive session and if more than one remote file is being accessed).- ...
Not used.
- .class
Signifier for the dataframe class.
default:
NULLukaq functions, by default, will return
tbl_dfs if the tibble package is installed, but will otherwise returndata.frames..classcan override this behaviour, and takes either"tbl"or"df", which sets the return class to betbl_dfordata.framerespectively.
References
With thanks to Trevor Davies and Ricardo Plc for preparing and hosting the data