Type: | Package |
Title: | Week of the year and weekday according to ISO 8601 |
Version: | 0.6-2 |
Date: | 2011-09-07 |
Author: | Uwe Block <u.block.mz@googlemail.com>, using an algorithm by Hatto von Hatzfeld <hatto@salesianer.de> |
Maintainer: | Uwe Block <u.block.mz@googlemail.com> |
Imports: | stringr |
Suggests: | testthat |
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. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
LazyLoad: | yes |
Collate: | 'ISOweek.R' 'ISOweekday.R' 'date2ISOweek.R' 'ISOweek2date.R' 'ISOweek-internal.R' |
Packaged: | 2011-09-07 06:45:51 UTC; Uwe |
Repository: | CRAN |
Date/Publication: | 2011-09-07 07:25:10 |
NeedsCompilation: | no |
Week of the year according to ISO 8601
Description
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.
Usage
ISOweek(date)
Arguments
date |
Vector which can be coerced to class
|
Details
According to ISO 8601, the year of the week can differ from the calendar year (see the examples).
Value
A character vector of year and week in format
"%Y-W%V
"
Author(s)
Hatto von Hatzfeld hatto@salesianer.de, adopted to R by Uwe Block u.block.mz@googlemail.com
References
http://www.salesianer.de/util/kalwoch.html
See Also
strptime
for a description of the date
formats and references on ISO 8601.
isoWeekYear
for an
alternative implementation.
Examples
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))
Converts date from week notation according to ISO 8601 to standard notation
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
ISOweek2date(weekdate)
Arguments
weekdate |
A character vector of year, week, and
weekday in format " |
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
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)
Day of week according to ISO 8601
Description
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.
Usage
ISOweekday(date)
Arguments
date |
Vector which can be coerced to class
|
Value
An integer vector of weekdays (1-7, Monday is 1)
Author(s)
Uwe Block u.block.mz@googlemail.com
See Also
Examples
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))
Converts date from standard notation to week notation according to ISO 8601
Description
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.
Usage
date2ISOweek(date)
Arguments
date |
Vector which can be coerced to class
|
Details
According to ISO 8601, the year of the week can differ from the calendar year (see the examples).
Value
A character vector of year, week, and weekday in format
"%Y-W%V-%u
"
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
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))
Date of the nearest Thursday of a given date
Description
This internal function returns the date of the Thursday of the week in which the given date is located.
Usage
thursday0(date)
Arguments
date |
Vector which can be coerced to class
|
Details
The week starts on Monday and ends on Sunday.
Value
A vector of dates of the nearest Thursdays
Weekday as integer number (0-6, Monday is 0)
Description
This internal function returns the weekday of a given date.
Usage
weekday0(date)
Arguments
date |
Vector which can be coerced to class
|
Details
The week starts on Monday and ends on Sunday.
Value
An integer vector of weekdays (0-6, Monday is 0)
See Also
Calendar year of a given date
Description
This internal function returns the year with century as integer.
Usage
year0(date)
Arguments
date |
Vector which can be coerced to class
|
Value
An integer vector of years