Learn R Programming

chron (version 2.3-63)

dates: Generate Dates and Times Components from Input

Description

Create objects which represent dates or times.

Usage

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

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

Value

An object of class dates or times, depending of the function called. Functions dates and times return objects inheriting from dates and times, respectively. They call

chron() if x does not belong to any of the chronological classes.

Arguments

x

For dates and times: 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. For as.dates and as.times: an R object.

...

For dates and times: further arguments to be passed to chron(). For as.dates and as.times: further arguments passed to or from other methods.

See Also

chron, times, seq.dates, cut.dates

Examples

Run this code
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

Run the code above in your browser using DataLab