Skip to content

Commit

Permalink
refactor to reduce risk for side-effects, #1154
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvanhees committed Jun 24, 2024
1 parent fc693ae commit 0cf0c8e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/g.imputeTimegaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ g.imputeTimegaps = function(x, sf, k=0.25, impute = TRUE,
}
# refill if first value is not consecutive from last value in previous chunk
if (!is.null(PreviousLastTime)) {
first_deltatime = diff(c(as.numeric(PreviousLastTime), x$time[1]))
if (!inherits(x = PreviousLastTime, what = "numeric") &&
inherits(x = x$time[1], what = "numeric")) {
PreviousLastTime = as.numeric(PreviousLastTime)
}
first_deltatime = diff(c(PreviousLastTime, x$time[1]))
if (!is.numeric(first_deltatime)) { # in csv axivity, the time is directly read as numeric (seconds)
units(first_deltatime) = "secs"
first_deltatime = as.numeric(first_deltatime)
Expand Down

0 comments on commit 0cf0c8e

Please sign in to comment.