README.md

emitr

Build Status

emitr is an R package to help organise and analyse on-road vehicle emissions data.

Installation

The development version:

# Install dependencies
devtools::install_github("skgrange/threadr")
devtools::install_github("skgrange/databaser")

# Install emitr
devtools::install_github("skgrange/emitr")

Usage

emitr was primarily developed so data from a number of field campaigns could be integrated into a single database and interacted with in a consistent way. This represents a significant challenge because the units used, naming conventions, and what variables are used during a vehicle capture and what details are retrieved using a registration plate based data service can be diverse.

This package has been developed with SQLite and PostgreSQL databases and will return tibbles, but there are some vector returns too.

Importing by vehicle

Importing vehicle capture and detail data by vehicle registration is easy. A vector of registrations can be used and the function will handle the rest.

# Get a random sample of vehicle registrations
registrations <- sample_registrations(con, 10)

# Get details for these registrations
data_emissions <- import_vehicle_emissions(con, registration = registrations)

# Quite a wide table
ncol(data_emissions)

[1] 100

Importing by monitoring location or field session

More useful for on-road emission data analysis is the ability to import data based on monitoring location (a site) or monitoring sessions (generally a site/day/instrument triad). The site or session integer keys need to be known first which can be found in the sites and sessions tables. Here is an example of usage:

# Get site information
data_sites <- import_sites(con)

# Get session information
data_sessions <- import_sessions(con)

# Get details for two sites
data_emissions_two_sites <- import_by_site(con, site = c(1, 101))

# Get details for a session
data_emssions_three_sessions <- import_by_session(con, session = c(10, 320, 532))

Database schema

Here.

Current database size

db_size(con, unit = "gb")
[1] 3.556434


skgrange/emitr documentation built on Oct. 2, 2019, 3:45 p.m.