filter_time() can be used to filter time series data according to a specific time interval. Traditionally, filtering by time can be messy due to the circular nature of time and the 24 hour clock. filter_time() uses circular statistics to convert time to degrees, which enables time series data to be filtered by time intervals that include midnight and span different dates (i.e. '23:00:00' to '04:00:00') without issue. Because filter_time() is agnostic to date, time series data can easily be filtered across multiple days.

filter_time(
  df,
  t_var = NULL,
  t1 = NULL,
  t2 = NULL,
  span_days = FALSE,
  summary_tbl = TRUE
)

Arguments

df

a data frame with a datetime or time column.

t_var

character; name of time or datetime column to filter.

t1

character; start time of filtering interval. Start and and times should be in 'HH:MM:SS' format.

t2

character; end time of filtering interval.

span_days

logical; does the filtering interval include midnight? Default = FALSE.

summary_tbl

logical; if TRUE (default), a summary table is included in the output showing the number of observations occurring in each hour of the filtering interval.

Examples


  filter_time(zoo_trip, t_var = 'Date_Time', t1 = '13:00:00', t2 = '14:30:00',
              summary_tbl = TRUE, span_days = TRUE)
#> Error in filter_time(zoo_trip, t_var = "Date_Time", t1 = "13:00:00", t2 = "14:30:00",     summary_tbl = TRUE, span_days = TRUE): could not find function "filter_time"