Title: | Week of the year and weekday according to ISO 8601 |
---|---|
Description: | This is an substitute for the %V and %u formats which are not implemented on Windows. In addition, the package offers functions to convert from standard calender format yyyy-mm-dd to and from ISO 8601 week format yyyy-Www-d. |
Authors: | Uwe Block <[email protected]>, using an algorithm by Hatto von Hatzfeld <[email protected]> |
Maintainer: | Uwe Block <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.6-2 |
Built: | 2024-11-29 08:45:19 UTC |
Source: | CRAN |
This function returns the year, the week of the year, and
the day of week of a given date according to ISO 8601. It
is an substitute for the %Y-W%V-%u
format which
is not implemented on Windows.
date2ISOweek(date)
date2ISOweek(date)
date |
Vector which can be coerced to class
|
According to ISO 8601, the year of the week can differ from the calendar year (see the examples).
A character vector of year, week, and weekday in format
"%Y-W%V-%u
"
Uwe Block [email protected]
strptime
for a description of the date
formats and references on ISO 8601.
x <- paste(1999:2011, "-12-31", sep = "") y <- as.Date(x) data.frame(date = format(y), weekdate = date2ISOweek(y)) data.frame(date = x, weekdate = date2ISOweek(x))
x <- paste(1999:2011, "-12-31", sep = "") y <- as.Date(x) data.frame(date = format(y), weekdate = date2ISOweek(y)) data.frame(date = x, weekdate = date2ISOweek(x))
This function returns the year and the week of the year
of a given date according to ISO 8601. It is an
substitute for the %Y-W%V
format which is not
implemented on Windows.
ISOweek(date)
ISOweek(date)
date |
Vector which can be coerced to class
|
According to ISO 8601, the year of the week can differ from the calendar year (see the examples).
A character vector of year and week in format
"%Y-W%V
"
Hatto von Hatzfeld [email protected], adopted to R by Uwe Block [email protected]
http://www.salesianer.de/util/kalwoch.html
strptime
for a description of the date
formats and references on ISO 8601.
isoWeekYear
for an
alternative implementation.
x <- paste(1999:2011, "-12-31", sep = "") y <- as.Date(x) data.frame(date = format(y), week = ISOweek(y)) data.frame(date = x, week = ISOweek(x))
x <- paste(1999:2011, "-12-31", sep = "") y <- as.Date(x) data.frame(date = format(y), week = ISOweek(y)) data.frame(date = x, week = ISOweek(x))
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
.
ISOweek2date(weekdate)
ISOweek2date(weekdate)
weekdate |
A character vector of year, week, and
weekday in format " |
According to ISO 8601, the year of the week can differ from the calendar year (see the examples).
A vector of class Date
Uwe Block [email protected]
strptime
for a description of the date
formats and references on ISO 8601.
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)
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)
This function returns the weekday of a given date
according to ISO 8601. It is an substitute for the
"%u
" format which is not implemented on Windows.
ISOweekday(date)
ISOweekday(date)
date |
Vector which can be coerced to class
|
An integer vector of weekdays (1-7, Monday is 1)
Uwe Block [email protected]
x <- paste(1999:2011, "-12-31", sep = "") y <- as.Date(x) data.frame(date = format(y), weekday = ISOweekday(y)) data.frame(date = x, weekday = ISOweekday(x))
x <- paste(1999:2011, "-12-31", sep = "") y <- as.Date(x) data.frame(date = format(y), weekday = ISOweekday(y)) data.frame(date = x, weekday = ISOweekday(x))