Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

splitByDate

Divide up a data frame by time


Description

Utility function to prepare input data for use in openair functions

Usage

splitByDate(
  mydata,
  dates = "1/1/2003",
  labels = c("before", "after"),
  name = "split.by"
)

Arguments

mydata

A data frame containing a date field in hourly or high resolution format.

dates

A date or dates to split data by.

labels

Labels for each time partition.

name

The name to give the new column to identify the periods split

Details

This function partitions a data frame up into different time segments. It produces a new column called controlled by name that can be used in many openair functions. Note that there must be one more label than there are dates. See examples below and in full openair documentation.

Author(s)

David Carslaw

Examples

## split data up into "before" and "after"
mydata <- splitByDate(mydata, dates = "1/04/2000",
labels = c("before", "after"))

## split data into 3 partitions:
mydata <- splitByDate(mydata, dates = c("1/1/2000", "1/3/2003"),
labels = c("before", "during", "after"))

openair

Tools for the Analysis of Air Pollution Data

v2.10-0
GPL (>= 2)
Authors
David Carslaw [aut, cre], Karl Ropkins [aut]
Initial release
2022-06-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.