[R] extract week from date

Thomas Lumley tlumley at u.washington.edu
Thu Apr 11 19:14:57 CEST 2002

On Thu, 11 Apr 2002, Juan Ramon Gonzalez wrote:

> Hello R-users,
> Does anyone know how obtain the week of a date?
> (in SPPS the instruction is "xdate.week")

Extract the day and divide by seven?

as.POSIXlt(a.date)$yday %/% 7

Perhaps add 1 if you want the year to start at week 1 rather than week 0.


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list