build_date_factor {dataPreparation}R Documentation

Date Factor

Description

Map a vector of dates to a factor at one of these levels "yearmonth", "yearquarter", "quarter", "month"

Usage

build_date_factor(data_set, type = "yearmonth")

Arguments

data_set

A vector of date values

type

One of "year", "yearquarter", "yearmonth", "quarter", "month"

Details

The resulting vector is an ordered factor of the specified type (e.g. yearmonth)

Examples

library(data.table)
data_set <- as.Date(c("2014-01-01", "2015-01-01", "2015-06-01"))
build_date_factor(data_set, type = "yearmonth")
build_date_factor(data_set, type = "yearquarter")
build_date_factor(data_set, type = "yearquarter")


[Package dataPreparation version 1.0.4 Index]