four.digit.year: Correct conversion of years to four digit format

View source: R/four.digit.year.R

four.digit.yearR Documentation

Correct conversion of years to four digit format

Description

Converts from two to four digit representation of years correcting the century for years earlier than that specified. Addresses the fact that under POSIX specifications, values 00 to 68 are prefixed by 20 and 69 to 99 by 19 when converting from two digit years, which can affectlonger time series and older data sets.

Usage

four.digit.year(x, year=1968)

Arguments

x

A vector of POSIXct dates, presumably with some years (often those earlier than 1969) assigned to the wrong century.

year

The year (in four digit format) indicating the cutoff for setting the century to 1900's or 2000's.

Value

A vector of same length as input with years in four digit format.

Author(s)

Nick Bond <n.bond@latrobe.edu.au>

See Also

strptime.

Examples

x <- as.POSIXct(c("01/01/43","01/01/68","01/01/69","01/01/99","01/01/04"), format="%d/%m/%y")
x
four.digit.year(x, year=1968)
four.digit.year(x, year=1942)

hydrostats documentation built on June 1, 2022, 9:06 a.m.