| as.Date {zoo} | R Documentation |
Coercion to the Date Class
Description
Alternative to the as.Date coercion function from
base R which was necessary to make sure that the default origin
in the as.Date numeric had a default (January 1, 1970)
whereas the method in base R long had no default.
Usage
as.Date(x, ...)
## S3 method for class 'numeric'
as.Date(x, origin, ...)
## S3 method for class 'ts'
as.Date(x, offset = 0, ...)
## S3 method for class 'yearmon'
as.Date(x, frac = 0, ...)
## S3 method for class 'yearqtr'
as.Date(x, frac = 0, ...)
Arguments
x |
an object to be converted. |
origin |
a |
offset |
numeric offset to be added to the time scale prior to coercion. |
frac |
numeric between 0 and 1 inclusive that indicates the fraction of the way through the period that the result represents. The default is 0 which means the beginning of the period. |
... |
further arguments to be passed from or to other methods. |
Value
An object of class Date.
See Also
Examples
## day zero (epoch): Jan 1, 1970
as.Date(0)
## conversion of July 2000 to date (beginning, mid or end of month)
ym <- yearmon(2000.5)
as.Date(ym, frac = 0)
as.Date(ym, frac = 0.5)
as.Date(ym, frac = 1)
## conversion of quarterly time series to dates (beginning of the months)
x <- ts(1:4, start = 2000, freq = 4)
as.Date(x)
[Package zoo version 1.9-1 Index]