Hi,

I am having a trouble parsing dates using strptime() that I get in the
format of year and week number. The data looks like this "201127" which
means year 2011 and week 27. I would like to graph this using ggplot but
then I get a gap between 201054 and 201101 so I thought I would just easily
convert it.

I tried to use strptime and as.Date and the format string of %Y%W but it
seems to only parse the year out of the string and then return today's month
and date. Can anyone point me where I am going wrong or another avenue to
try?

David

> strptime("201101","%Y%W")[1] "2011-07-06"

> strptime("201001","%Y%W")[1] "2010-07-06"

> strptime("201114","%Y%W")[1] "2011-07-06"

> strptime("201130","%Y%W")[1] "2011-07-06"



> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] RSiteSearch_1.0-7 sos_1.3-0         brew_1.0-6        ggplot2_0.8.9
[5] proto_0.3-9.1     reshape_0.8.4     plyr_1.4          RODBC_1.3-2

loaded via a namespace (and not attached):
[1] digest_0.4.2 tools_2.12.2

        [[alternative HTML version deleted]]

______________________________________________
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