Learn R Programming

mMARCH.AC (version 3.3.4.0)

NormalizeGGIRDate: Normalize GGIR dates to ISO format

Description

Convert dates from heterogeneous GGIR output formats into a standard ISO 8601 date format ("YYYY-MM-DD"). This function performs format harmonization only and does not apply any time zone conversion.

Usage

NormalizeGGIRDate(x)

Value

A character vector of dates formatted as "YYYY-MM-DD".

Arguments

x

A vector of dates. Can be of class character, factor, numeric, Date, or POSIXct. Mixed formats are allowed.

Details

GGIR summary files often contain dates stored as formatted strings, Excel serial numbers, R Date numbers, or POSIX timestamps. This function detects the input type and converts all values into a consistent ISO date representation ("YYYY-MM-DD"), suitable for merging and aligning GGIR outputs.

Numeric values between 20000 and 60000 are treated as Excel date serials (origin "1899-12-30"). Other numeric values are treated as R Date values (origin "1970-01-01").

Examples

Run this code
NormalizeGGIRDate("2019/01/03")
NormalizeGGIRDate("03-01-2019")
NormalizeGGIRDate(43466)        # Excel date
NormalizeGGIRDate(Sys.time())   # POSIXct


Run the code above in your browser using DataLab