isoWeekYear {surveillance}R Documentation

Find ISO week and ISO year of a vector of Date objects on Windows

Description

This function extracts the ISO week and ISO year of a Date according to the ISO 8601 specification. Note that this function does nothing else than format.Date(x, "%G") and format.Date(x, "%V") 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 .Platform$OS.type information reveals a Windows system. The function also provides three additional strptime formatting strings: "%Q" (the quarter of a date as a numeric), "%OQ" (the quarter of a date in roman) and "%q" (day within the quarter). These are, e.g., used by linelist2sts.

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 ISOYear and ISOWeek containing the corresponding results.

Author(s)

Gustaf Rydevik

Source

The code to find the ISO week and year on Windows is by Gustaf Rydevik posted at https://stat.ethz.ch/pipermail/r-help/2010-May/239531.html

Examples

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

[Package surveillance version 1.16.1 Index]