Pele wrote:
Hi R users,
I have a factor variable called date as shown below: Can anyone share the
best / most efficient way to extract year and week (e.g. year = 2006, week
= 52 for first record, etc..)? My data set has 1 million records.
DATE
11DEC2006
11SEP2006
01APR2007
02DEC2007
Since I am not in the correct locale:
Sys.setlocale(locale="C")
date <- strptime(DATE, "%d%B%Y")
format(date, "%Y")
format(date, "%W") # which is certainly not 52
Uwe Ligges
Thanks in advance for any help!
______________________________________________
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.