Learn R Programming

CFtime (version 1.5.1)

slice: Which time steps fall within two extreme values

Description

Given two extreme character timestamps, return a logical vector of a length equal to the number of time steps in the CFTime instance with values TRUE for those time steps that fall between the two extreme values, FALSE otherwise. This can be used to select slices from the time series in reading or analysing data.

Usage

slice(x, extremes, rightmost.closed = FALSE)

Value

A logical vector with a length equal to the number of time steps in x with values TRUE for those time steps that fall between the two extreme values, FALSE otherwise. The earlier timestamp is included, the later timestamp is excluded. A specification of c("2022-01-01", "2023-01-01")

will thus include all time steps that fall in the year 2022.

Arguments

x

The CFTime instance to operate on.

extremes

Character vector of two timestamps that represent the extremes of the time period of interest. The timestamps must be in increasing order. The timestamps need not fall in the range of the time steps in argument `x.

rightmost.closed

Is the larger extreme value included in the result? Default is FALSE.

Details

If bounds were set these will be preserved.

Examples

Run this code
t <- CFtime("hours since 2023-01-01 00:00:00", "standard", 0:23)
slice(t, c("2022-12-01", "2023-01-01 03:00"))

Run the code above in your browser using DataLab