week: Get/set weeks component of a date-time

Description Usage Arguments Value References See Also Examples

View source: R/accessors-week.r

Description

week() returns the number of complete seven day periods that have occurred between the date and January 1st, plus one.

isoweek() returns the week as it would appear in the ISO 8601 system, which uses a reoccurring leap week.

epiweek() is the US CDC version of epidemiological week. It follows same rules as isoweek() but starts on Sunday. In other parts of the world the convention is to start epidemiological weeks on Monday, which is the same as isoweek.

Usage

1
2
3
4
5
6
7
week(x)

week(x) <- value

isoweek(x)

epiweek(x)

Arguments

x

a date-time object. Must be a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, timeDate, xts, its, ti, jul, timeSeries, or fts object.

value

a numeric object

Value

the weeks element of x as an integer number

References

http://en.wikipedia.org/wiki/ISO_week_date http://www.cmmcp.org/epiweek.htm

See Also

isoyear()

Examples

1
2
3
4
5
x <- ymd("2012-03-26")
week(x)
week(x) <- 1
week(x) <- 54
week(x) > 3

Example output

Attaching package: 'lubridate'

The following object is masked from 'package:base':

    date

[1] 13
[1] FALSE

lubridate documentation built on Nov. 17, 2017, 6:56 a.m.