date_functions: WCCMH date functions

Description Usage Arguments Value Note Examples

Description

standardize date classes

Usage

1
2
3
4
5
.date_convert(x, format, origin)

date_convert(x, format = NULL, origin = "1970-01-01")

date_expansion(start_date, end_date, types = c("qtr", "mon", "fy"))

Arguments

x

A character vector of dates.

format

The format of the incoming date.

origin

The origin (day 1) for the date.

start_date

The start date for date_expansion, must become a date if not already one via date_convert function.

end_date

The end date for date_expansion, must become a date if not already one via date_convert function.

types

A character vector defining which types to be returned. Choices are any combination of c("fy", "qtr", "mon"). Default is all.

Value

A vector of dates of class 'Date'.

Note

.date_convert could be moved to C++. lapply() loses the class 'Date', perhapse a better method exists. Also, today: use S3 methods instead of a switch statement.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
date_convert(x = c("10/1/2015", "10/2/2015"))
date_convert(x = factor("10/1/2015"))
x <- factor(c("10/1/2014", "10/2/2015", "10/1/2014", NA))
date_convert(x)
x <- c("10/1/2014", "10/2/2015", "10/1/2014", NA)
date_convert(x)
x <- as.Date("10/1/2014", format = "%m/%d/%Y")
date_convert(x)
x <- as.POSIXct(c("2014-10-1", "2015-10-2", NA))
date_convert(x)
date_convert(x = as.Date("2014-10-1"))
date_expansion(start_date = "10/1/2014", end_date = "9/30/2015")

JamesDalrymple/wccmh documentation built on May 7, 2019, 10:20 a.m.