# durCalc: Filter Dataset by Date Duration In timelineS: Timeline and Time Duration-Related Tools

## Description

Calculates the duration between two dates, use it as a filter to select rows that satisfy the length criteria. Returns the dataset with additional columns regarding the length of durations in different units.

## Usage

 ```1 2``` ```durCalc(df = NULL, start, end, timeunit = "day", filterlength = NA, filterlonger = TRUE, year = 365.25, month = 30.42) ```

## Arguments

 `df` Data frame containing start and end dates. `start` Column in df for start dates or a date to use as start date. `end` Column in df for end dates or a date to use as a end date. `timeunit` Unit of time to be used in plots. `"day(s)"`, `"week(s)"`, `"month(s)"`, `"quarter(s)"`, `"semiannual"`, `"halfyear"`,or `"year(s)"`. `filterlength` A time length to use as filter. `filterlonger` If TRUE, the function gives rows with longer durations than specified in filterlength. If FALSE, gives rows with shorter durations. `year` Number of days to use as a year. Default is 365.25. `month` Number of days to use as a month. Default is 30.42.

## Details

Additional columns returned with the filtered rows are: length of duration in days, in specified time unit, and in calendar units, and how much longer/shorter the durations are compared to filter length in calendar units.

If no `filterlength` is provided, then returns all rows with length of duration in days and calendar units.

You can use dates for `start` and `end` and provide no `df` to get the length of duration between the dates in calendar units. See example.

## Value

A subset of original data frame with additional columns in specified time units and calendar units.

## Author(s)

Dahee Lee

`durPlot`, `durSummary`
 ```1 2 3 4 5 6 7 8``` ```### Filter people who lived longer than 85 years durCalc(life_exp, start = "Birth", end = "Death", timeunit = "years", filterlength = 85) ### How old each person would be as of January 1, 2000 if they were alive durCalc(life_exp, start = "Birth", end = as.Date("2000-1-1"), timeunit = "years") ### Use as unit-converter between two dates durCalc(start = as.Date("2010-12-1"), end = as.Date("2015-4-26"), timeunit = "weeks") ```