Description Usage Arguments Details Value Author(s) See Also Examples
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.
1 2 |
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. |
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. |
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.
A subset of original data frame with additional columns in specified time units and calendar units.
Dahee Lee
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.