On Dec 17, 2010, at 11:08 AM, Luca Meyer wrote:

x= factor(c("2009-03-30 00:00:00", "2009-04-06 00:00:00", "2009-04-13 00:00:00", "2009-04-20 00:00:00", "2009-04-27 00:00:00", "2009-05-04 00:00:00" ,"2009-05-11 00:00:00", "2009-05-18 00:00:00"))
require(lubridate)
xd=as.POSIXct(x)
week(xd)
# [1] 13 14 15 16 17 18 19 20
 year(xd)
# [1] 2009 2009 2009 2009 2009 2009 2009 2009
 paste(year(xd), " W",week(xd), sep="")
#[1] "2009 W13" "2009 W14" "2009 W15" "2009 W16" "2009 W17" "2009 W18" "2009 W19" "2009 W20"



David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to