ISOweek2date: Converts date from week notation according to ISO 8601 to...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/ISOweek2date.R

Description

This function returns the date of a given weekdate (year, week of the year, day of week according to ISO 8601). It is the inverse function to date2ISOweek.

Usage

1
  ISOweek2date(weekdate)

Arguments

weekdate

A character vector of year, week, and weekday in format "%Y-W%V-%u"

Details

According to ISO 8601, the year of the week can differ from the calendar year (see the examples).

Value

A vector of class Date

Author(s)

Uwe Block u.block.mz@googlemail.com

See Also

strptime for a description of the date formats and references on ISO 8601.

Examples

1
2
3
4
5
6
7
w <- paste("2009-W53", 1:7, sep = "-")
data.frame(weekdate = w, date = ISOweek2date(w))
# convert from calendar date to week date and back to calendar date
x <- paste(1999:2011, "-12-31", sep = "")
w <- date2ISOweek(x)
d <- ISOweek2date(w)
data.frame(date = x, weekdate = w, date2 = d)

Example output

    weekdate       date
1 2009-W53-1 2009-12-28
2 2009-W53-2 2009-12-29
3 2009-W53-3 2009-12-30
4 2009-W53-4 2009-12-31
5 2009-W53-5 2010-01-01
6 2009-W53-6 2010-01-02
7 2009-W53-7 2010-01-03
         date   weekdate      date2
1  1999-12-31 1999-W52-5 1999-12-31
2  2000-12-31 2000-W52-7 2000-12-31
3  2001-12-31 2002-W01-1 2001-12-31
4  2002-12-31 2003-W01-2 2002-12-31
5  2003-12-31 2004-W01-3 2003-12-31
6  2004-12-31 2004-W53-5 2004-12-31
7  2005-12-31 2005-W52-6 2005-12-31
8  2006-12-31 2006-W52-7 2006-12-31
9  2007-12-31 2008-W01-1 2007-12-31
10 2008-12-31 2009-W01-3 2008-12-31
11 2009-12-31 2009-W53-4 2009-12-31
12 2010-12-31 2010-W52-5 2010-12-31
13 2011-12-31 2011-W52-6 2011-12-31

ISOweek documentation built on May 1, 2019, 10:08 p.m.