Skip to content

Commit

Permalink
Merge branch 'expand-time-check'
Browse files Browse the repository at this point in the history
add comments go time-gap-check
  • Loading branch information
srearl committed Jun 14, 2018
1 parent 57aec79 commit 3cc30bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/time_gap_checker.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@

time_gap_checker <- function(dat, datetimeVar, gapThreshold) {

# confirm that the date time variable is of type posixct or posixlt
if (!(is.POSIXct(tower[['timestamp']]) | is.POSIXlt(tower[['timestamp']]))) {
stop("variable to check must be of type POSIXct or type POSIXlt")
}

datetimeVec <- dat[[datetimeVar]]
timeGap <- datetimeVec - lag(datetimeVec)

# set gap threshold to the standard deviation of the time step if not provided
if (missing(gapThreshold)) {
gapThreshold <- sd(timeGap, na.rm = T)
}

sequenceGap <- timeGap > gapThreshold

# set flags according to:
# -1 not run
# 0 passed
# 1 fail
sequenceGap <- ifelse(is.na(sequenceGap), -1,
ifelse(sequenceGap == TRUE, 1,
ifelse(sequenceGap == FALSE, 0, NA)
Expand Down

0 comments on commit 3cc30bc

Please sign in to comment.