Description Usage Arguments Details Examples
Map a vector of dates to a factor at one of these levels "yearmonth", "yearquarter", "quarter", "month"
| 1 2 3 4 5 6 | 
| dateVec | A vector of date values | 
| type | One of "year", "yearquarter", "yearmonth", "quarter", "month" | 
| minDate | (Default = min(dateVec)) When determining factor levels, use this date to set the min level, after coercing 
dates to the specified  | 
| maxDate | (Default = max(dateVec)) When determining factor levels, use this date to set the max level. (See minDate, above) | 
The resulting vector is an ordered factor of the specified type (e.g. yearmonth)
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | library(data.table)
dts <- as.Date(c("2014-1-1", "2015-1-15", "2015-6-1"))
date_factor(dts, type = "yearmonth")
date_factor(dts, type = "yearquarter")
date_factor(
  dateVec = dts, 
  type = "yearquarter", 
  minDate = as.Date("2015-1-1"), 
  maxDate = as.Date("2015-12-31")
)
date_factor(
  dateVec = as.Date(character(0)), 
  type = "yearmonth", 
  minDate = as.Date("2016-1-1"), 
  as.Date("2016-12-31")
)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.