ISOweekday: Day of week according to ISO 8601

Description Usage Arguments Value Author(s) See Also Examples

View source: R/ISOweekday.R

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

1

Arguments

date

Vector which can be coerced to class Date

Value

An integer vector of weekdays (1-7, Monday is 1)

Author(s)

Uwe Block u.block.mz@googlemail.com

See Also

strptime

Examples

1
2
3
4
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))

Example output

         date weekday
1  1999-12-31       5
2  2000-12-31       7
3  2001-12-31       1
4  2002-12-31       2
5  2003-12-31       3
6  2004-12-31       5
7  2005-12-31       6
8  2006-12-31       7
9  2007-12-31       1
10 2008-12-31       3
11 2009-12-31       4
12 2010-12-31       5
13 2011-12-31       6
         date weekday
1  1999-12-31       5
2  2000-12-31       7
3  2001-12-31       1
4  2002-12-31       2
5  2003-12-31       3
6  2004-12-31       5
7  2005-12-31       6
8  2006-12-31       7
9  2007-12-31       1
10 2008-12-31       3
11 2009-12-31       4
12 2010-12-31       5
13 2011-12-31       6

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

Related to ISOweekday in ISOweek...