Learn R Programming

surveillance (version 1.2-1)

isoWeekYear: Find ISO week and ISO year of a vector of Date objects

Description

This function extracts the ISO week and ISO year of Date according to the ISO 8601 specification. Note that this function does nothing else than format.Date(x, " would do on Mac/Unix computers. However, this is not implemented on Windows.

A small internal wrapper for format.Date (called formatDate) thus directs all calls having one of these format strings to this function, if the sessionInfo()[[1]]$os information reveals a Windows system.

Usage

isoWeekYear(Y, M=NULL, D=NULL)

Arguments

Y
Date object (POSIX) or the year. Can be a vector.
M
month, NULL if Y is a Date object)
D
day, NULL if Y is a Date object)

Value

  • A list with entries ISOWeek and ISOweek containing the corresponding results.

Details

The code is by Gustaf Rydevik posted at http://tolstoy.newcastle.edu.au/R/e10/help/10/05/5588.html

Examples

Run this code
dates <- as.Date(c("2002-12-31","2003-01-01","2003-01-06"))
isoWeekYear(dates)

Run the code above in your browser using DataLab