gapval: Add no-data gaps to a time series

Description Usage Arguments Value Examples

Description

This function allows you to inject windows of no data into a time series. This is meant to mimic a broken sensor that is sending no signal for a specified period of time.

Usage

1
gapval(y, n = 1, min.dur = 1, max.dur = 1, plot = F)

Arguments

y

The time series into which you would like to inject an error. No default.

n

The number of error events you would like to inject. Defaults to 1.

min.dur

The minimum duration, in time steps, for an error event. A random duration length is chosen to fall between the minimum and maximum (see below) duration event. Defaults to 1.

max.dur

The maximum duration, in time steps, for an error event. A random duration length is chosen to fall between the minimum (see above) and maximum duration event. Defaults to 1.

plot

A logical value (T or F) indicating if a plot should be returned. Defaults to F.

Value

Returns a list with three components and an optional plot. The three components are the original time series, the new error-injected time series, and a vector of 1 and 0 that indicate the locations (time steps) where errors were injected. The plot is a graphical illustration of these three components.

Examples

1
2
3
4
5
6
7
library(setset)
data(simseries)
d1 <- simseries
str(d1)
gapval(d1$v1, n=3, min.dur=10000, max.dur=20000, plot=T)
d2 <- gapval(d1$v1, n=3, min.dur=10000, max.dur=20000, plot=T)
str(d2)

tmeeha/setset documentation built on May 31, 2019, 4:38 p.m.