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

Description Usage Arguments Value Author(s) See Also Examples

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

1
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

1
2
3
4
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)

Example output

[1] "2043-01-01 UTC" "2068-01-01 UTC" "1969-01-01 UTC" "1999-01-01 UTC"
[5] "2004-01-01 UTC"
[1] 2043 2068 1969 1999 2004
[1] 1943 1968 1969 1999 2004

hydrostats documentation built on May 6, 2019, 1:02 a.m.