date | R Documentation |
These are wrapper functions to extract a date field from an object, such as a character string or a data frame.
date(x, ...)
## Default S3 method:
date(x, year, month, day, ...)
## S3 method for class 'character'
date(x, ...)
## S3 method for class 'data.frame'
date(x, ...)
## Default S3 method:
day(x, ...)
## Default S3 method:
month(x, ...)
## Default S3 method:
year(x, ...)
x |
Object. |
... |
Further arguments. |
year |
Date year. |
month |
Date month. |
day |
Date day. |
Generally a POSIXct
or POSIXt
object.
date(default)
: Default date method.
date(character)
: Convert character string to date.
date(data.frame)
: Extract date from a data frame.
day(default)
: Default method for extracting day from a date.
month(default)
: Default method for extracting month from a date.
year(default)
: Default method for extracting year field from a date.
time
date() # Base method.
# Single day:
date(year = 2000, month = 9, day = 19)
# Entire month:
date(year = 2000, month = 9, day = 1:30)
# Sorts out YYYYMMDD and DDMMYYYY:
date(c("2000-01-19", "19-01-2000", "2000/01/19", "00-1-19"))
# Apply to data frame:
x <- data.frame(Year = 2000, Month = 01, Day = 1:30)
date(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.