Skip to content

Commit

Permalink
Merge pull request #47 from EvolEcolGroup/location_slice
Browse files Browse the repository at this point in the history
bug fix location_slice
  • Loading branch information
dramanica authored Apr 23, 2024
2 parents 453adbb + fe57ec6 commit 8017ed2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/time_bp_to_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
time_bp_to_index <- function(time_bp, time_steps) {
# give warning if some dates are too extreme
time_steps_ordered <- sort(time_steps)
# if you have only one time step within your database you cannot calculate the range between min and max time steps
# the following if statement was added because otherwise you would get NAs
if (length(time_steps_ordered) != 1) {
# calculate the range between the min and the max time steps
# this allow to check if the dates within your data frame are within a sensible range of the database's time steps
range_minmax <- c(
head(time_steps_ordered, n = 1)[1] -
(abs(head(time_steps_ordered, n = 2)[1] - head(time_steps_ordered, n = 2)[2]) / 2),
Expand All @@ -23,6 +28,7 @@ time_bp_to_index <- function(time_bp, time_steps) {
"might not make sense. The potentially problematic dates are:\n",
time_bp[which((time_bp < range_minmax[1]) | (time_bp > range_minmax[2]))]
)
}
}
# get indeces
time_indeces <-
Expand Down

0 comments on commit 8017ed2

Please sign in to comment.