at_intervals: Values of arbitrary time series at regular intervals.

Description Usage Arguments Details Value See Also Examples

Description

Time series are assumed to be structured as a data frame with one column being time stamps and the remaining columns being features that are observed. In general, features are observed irregularly and asynchronously. The purpose of this function is derive a regular sequenced, synchronised time series.

Usage

1
at_intervals(x, ..., na.rm = TRUE)

Arguments

x

A data frame

...

Arguments passed to seq method

na.rm

A logical scalar. Defaults to TRUE.

Details

The function is designed to be used with the dplyr family.

Value

A data frame

See Also

seq

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 x <- tibble::tribble(
   ~ts,                   ~x, ~y, ~z,
 #|----------------------|---|---|---|
   "2016-01-01 00:00:00", NA, 1,  1,
   "2016-01-01 00:05:00", 2,  NA, NA,
   "2016-01-01 00:10:00", 3,  3,  NA
   )

 x <- dplyr::mutate(x, ts = lubridate::ymd_hms(ts))

 at_intervals(x, by = "2 min", na.rm = FALSE)

NickPTaylor/pfatools documentation built on May 7, 2019, 6:07 p.m.