
Creates a time_rep
object for repeating time intervals
time_rep.Rd
The time_rep
function is used by the fetch
function internally. It
generates a list object with specified time intervals, and settings for
repeated sampling of environmental data before and after an original
datetime. The function validates input parameters to ensure that they are of
the correct types and meet certain conditions.
Arguments
- interval
A lubridate period indicating the time interval to repeat. It should be positive, e.g.
lubridate::days(14)
.- n_start
An integer indicating the number of steps before the original datetime from which the interval should start repeating. Default is -1. Note this is inclusive.
- n_end
An integer indicating the number of steps after the original datetime to which the interval should continue repeating. Default is 0. Note, this is exclusive.
- relative_to_start
Whether to create repeating time intervals relative to the start of the input time interval or end.
Examples
# Generates a time_rep object for a 14-day interval, starting 14 days before
# the original datetime and ending at the original datetime.
time_rep(lubridate::days(14))
#> $interval
#> [1] "14d 0H 0M 0S"
#>
#> $n_start
#> [1] -1
#>
#> $n_end
#> [1] 0
#>
#> $relative_to_start
#> [1] TRUE
#>
# Generate a time_rep object for multiple 14-day intervals, between 28
# periods before and ending 42 periods after the original datetime
time_rep(lubridate::days(14), -2, 3)
#> $interval
#> [1] "14d 0H 0M 0S"
#>
#> $n_start
#> [1] -2
#>
#> $n_end
#> [1] 3
#>
#> $relative_to_start
#> [1] TRUE
#>