getNewGapsInd: A function to create random gaps

Description Usage Arguments Value Author(s) Examples

View source: R/getNewGapsInd.R

Description

This function creates nGaps gaps of length lGaps in the time series timSer. It is used internally. The gaps do not overlay amongst them; they do not overlay pre-existing gaps either.

Usage

1
getNewGapsInd(timSer, lGaps, nGaps)

Arguments

timSer

The time series where the gaps will be created.

lGaps

The length of the gaps

nGaps

The number of gaps.

Value

A vector containing the indices of the gaps

Author(s)

Marina Saez Andreu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create time series
TS <- genTSExample(InKTSEnv = FALSE)[1:50,]

# Create 3 gaps of 7 NAs each
gInd <- getNewGapsInd(TS, 7, 3)

# Create time series duplicate and apply the gaps
TS1 <- TS
TS1$value[gInd] <- NA

#Compare
cbind(TS, TS1$value)

KarsTS documentation built on Jan. 16, 2021, 5:07 p.m.