date_format_unifier {dataPreparation}R Documentation

Unify dates format

Description

Unify every column in a date format to the same date format.

Usage

date_format_unifier(data_set, format = "Date")

Arguments

data_set

Matrix, data.frame or data.table

format

Desired target format: Date, POSIXct or POSIXlt, (character, default to Date)

Details

This function only handle Date, POSIXct and POSIXlt dates.
POSIXct format is a bit slower than Date but can keep hours-min.

Value

The same data_set set but with dates column with the desired format.

Examples

# build a data.table
require(data.table)
data_set <- data.table( column1 = as.Date("2016-01-01"), column2 = as.POSIXct("2017-01-01") )

# Use the function
data_set = date_format_unifier(data_set, format = "Date")

# Control result
sapply(data_set, class)
# return Date for both columns

[Package dataPreparation version 1.1.1 Index]