isoWeekYear {surveillance} | R Documentation |
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
.
isoWeekYear(Y, M=NULL, D=NULL)
Y |
Date object (POSIX) or the year. Can be a vector. |
M |
month, |
D |
day, |
A list with entries ISOYear
and ISOWeek
containing the
corresponding results.
Gustaf Rydevik
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
dates <- as.Date(c("2002-12-31","2003-01-01","2003-01-06")) isoWeekYear(dates)