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

dates

Generate Dates and Times Components from Input


Description

Create objects which represent dates or times.

Usage

dates(x, ...)
times(x, ...)

Arguments

x

a chron object, a character vector, or a numeric vector specifying time. If character, it must be in a format recognized by chron(). If numeric, it specifies Julian dates, i.e., number of days since an origin.

...

parameters for chron().

Value

An object of class dates or times, depending of the function called.

These functions return objects inheriting from dates and times, respectively. They call chron() if x does not belong to any of the chronological classes.

See Also

Examples

dts <- dates(c("02/27/92", "02/27/92", "01/14/92",
               "02/28/92", "02/01/92"))
dts
# [1] 02/27/92 02/27/92 01/14/92 02/28/92 02/01/92
class(dts)

x <- chron(dates = c("02/27/92", "02/27/92", "01/14/92", "02/28/92"),
           times = c("23:03:20", "22:29:56", "01:03:30", "18:21:03"))
dates(x)
# [1] 02/27/92 02/27/92 01/14/92 02/28/92

chron

Chronological Objects which can Handle Dates and Times

v2.3-56
GPL-2
Authors
David James [aut] (S original), Kurt Hornik [aut, trl, cre] (<https://orcid.org/0000-0003-4198-9911>), Gabor Grothendieck [ctb], 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.