Description Usage Arguments Methods (by class)
View source: R/date_functions.r
wp_date()
provides a generic function and several methods to transform
something into a date, just like as.Date()
from the base package.
While most methods were copied 1:1 from as.Date() some changes were made that
alter the usual behavior: (1) Whenever wp_date() is applied to an empty
string ""
or any other not-standard-unambiguous format the function
will return NA
and throw out a warning instead of simply kill itself
with an error. (2) Whenever, as.Date usually is in the need of an origin
supplied and does not get one wp_date()
will assume the origin to be
"1970-01-01" and throw an error instead of kill itself with an error. All
these changes are made with the special purpose to make wp_trend()
also with dirty, unreasonable data (e.g. "" or "2012-13-01" or "2012-02-32")
and are not recommended for any other than wikipediatrend internal use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | wp_date(x, ...)
## S3 method for class 'character'
wp_date(x, format = "", ...)
## Default S3 method:
wp_date(x, ...)
## S3 method for class 'numeric'
wp_date(x, origin, ...)
## S3 method for class 'factor'
wp_date(x, ...)
## S3 method for class 'POSIXct'
wp_date(x, tz = "UTC", ...)
## S3 method for class 'POSIXlt'
wp_date(x, ...)
|
x |
See |
... |
See |
format |
See |
origin |
See |
tz |
See |
character
: Difference to as.Date.character()
: Failing to
parse the date, wp_date()
will give return a warning and NA
instead of killing itself with an error.
default
: same as as.Date()
numeric
: Difference to as.Date.character()
: Whenever an
origin is needed but not supplied isntead of breaking, wp_date()
will raise a warning and proceed by assuming "1970-01-01" to be the origin
instead of killing itself with an error.
factor
: same as as.Date()
POSIXct
: same as as.Date()
POSIXlt
: using as.Date()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.