Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

as.date

Coerce Data to Dates


Description

Converts any of the following character forms to a Julian date: 8/31/56, 8-31-1956, 31 8 56, 083156, 31Aug56, or August 31 1956.

Usage

as.date(x, order = "mdy", ...)

Arguments

x

input data vector.

order

if x is character, defines the order in which the terms are assumed to appear in a xx/xx/xx date. The default is month/day/year; any permutation of mdy is legal.

...

if x is character, then any other arguments from mdy.date() can be used as well.

Details

If x is numeric, then floor(x) is returned, e.g., as.date(35) is the same as as.date(35.2) and gives February 5, 1960 (5Feb60). If x is character, the program attempts to parse it.

Value

For each date, the number of days between it and January 1, 1960. The date will be missing if the string is not interpretable.

See Also

Examples

as.date(c("1jan1960", "2jan1960", "31mar1960", "30jul1960"))

date

Functions for Handling Dates

v1.2-39
GPL-2
Authors
Terry Therneau [aut], Thomas Lumley [trl] (R port), Kjetil Halvorsen [trl] (R port), Kurt Hornik [trl, ctb, cre] (<https://orcid.org/0000-0003-4198-9911>, R port), R Core Team [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.