filter_multiple_dates: Filter a data.frame for multiple dates

Description Usage Arguments Details Value Author(s) Examples

View source: R/filter_mulitple_dates.R

Description

Filter a data.frame for multiple time periods

Usage

1
filter_multiple_dates(x, date_var, date_list, use_names = T)

Arguments

x

a data.frame

date_var

chr string of the name for the datetime column

date_list

a list of dates in the format of c(start, end). Dates will be used to filter data.frame, inclusive. Dates must be in POSIXct format.

use_names

logical If TRUE a new column will be added to label events based on names assigned to elements in date_list

Details

This function allows the user to filter a single data.frame for multiple time periods.

Value

Returns a data.frame

Author(s)

Julie Padilla

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
df <- data.frame(datetime = seq(from = as.POSIXct('2000-01-01')
, to = as.POSIXct('2000-02-01'), by = 'hour')
, value = rnorm(745))

events <- lapply(list(c('2000-01-02 0:00', '2000-01-02 05:00')
, c('2000-01-04 0:00', '2000-01-04 05:00')), as.POSIXct)

filter_multiple_dates(df, date_var = 'datetime', date_list = events, use_names = F)

## End(Not run)

LimnoTech/limnotools documentation built on May 17, 2019, 9:10 a.m.