epidate {epitools}R Documentation

Convert dates into multiple legible formats

Description

Convert character vector of dates into multiple legible formats.

Usage

epidate(x, format = "%m/%d/%Y", cal.dates = FALSE,
        before = 7, after = 7, sunday = TRUE)

Arguments

x

character vector of dates to be converted

format

format of character vector of dates

cal.dates

Calendar dates that contains x, starting 7 days 'before' (default) until 7 days 'after' x

before

defines lower limit of cal.dates: default is 7 days before earliest date in x

after

defines upper limit of cal.dates: default is 7 days after latest date in x

sunday

first day of the week is either Sunday (default) or Monday

Details

Dates can come in many formats (e.g., November 12, 2001, 12Nov01, 11/12/2001, 11/12/01, 2001-11-12) and need to be converted into other formats for data analysis, graphical displays, generating reports, etc.

There is tremendous flexibility in converting any character vector with sufficient information to be converted into a unique date. For complete options for the format option see strptime.

Value

dates

dates wtih date-time class

julian

number of days since 1970-01-01

mday

day of the month: 1-31

mon

month of the year: 0-11

month

month: January, February, March, ...

month2

month: Jan, Feb, Mar, ...

firstday

first day of the week: Sunday or Monday

week

week of the year: 0-53

year

year: YYYY

yr

year: YY

wday

day of the week: 0-6

weekday

weekday: Monday, Tuesday, Wednesday, ...

wkday

weekday: Mon, Tue, Wed, ...

yday

day of the year: 0-365

quarter

quarter of the year: Q1, Q2, Q3, Q4

cdates

Calendar dates that contains dates

cjulian

Julian calendar dates

Author(s)

Tomas Aragon, aragon@berkeley.edu, http://www.phdata.science

References

none

See Also

epitools: as.week

DateTimeClasses to learn about date-time classes

format.Date to convert character vector of dates into calendar dates with date-time class (done by epidate)

strptime to convert date-time character strings into a date-time class

Examples

#x <- c("12/1/03", "11/2/03", NA, "1/7/04", "1/14/04", "8/18/04")
#epidate(x, format = "%m/%d/%y")
#epidate(x, format = "%m/%d/%y", TRUE)
#
###convert vector of disease weeks into vector of mid-week dates
#dwk <- sample(0:53, 100, replace = TRUE)
#wk2date <- paste(dwk, "/", "Wed", sep="")
#wk2date[1:10]
#wk2date2 <- epidate(wk2date, format = "%U/%a")
#wk2date2$dates[1:20]

[Package epitools version 0.5-10.1 Index]