formatDate {EHRtemporalVariability}R Documentation

Function to transform dates into "Date" R format

Description

Given a data.frame object with a column of dates in 'character' format, it generates a new data.frame object with the dates transformed into "Date" R format.

Usage

formatDate(input, dateColumn, dateFormat = "%y/%m/%d", verbose = FALSE)

Arguments

input

A data.frame object with at least one column of dates.

dateColumn

The name of the column containing the date.

dateFormat

By default '%y/%m/%d'. Change it to the specific structure of your date format.

verbose

By default FALSE. Change it to TRUE to get an on-time log from the function.

Value

An object of class data.frame with the date column transform into 'Date' R class.

Examples


dataset <- read.csv2(system.file("extdata",
                                   "nhdsSubset.csv",
                                   package="EHRtemporalVariability"), 
                     sep  = ",",
                     header = TRUE, 
                     na.strings = "", 
                     colClasses = c( "character", "numeric", "factor",
                                     "numeric" , rep( "factor", 22 ) ) )
                     
datasetFormatted <- formatDate( 
              input         = dataset, 
              dateColumn    = "date", 
              dateFormat    = "%y/%m",
             )

[Package EHRtemporalVariability version 1.2.1 Index]