Tack on a day of the week (6 as the last day) for a point of reference for the conversion:
> dates <- paste('6.', 0:53, '.2011', sep = '') > dates [1] "6.0.2011" "6.1.2011" "6.2.2011" "6.3.2011" "6.4.2011" "6.5.2011" "6.6.2011" [8] "6.7.2011" "6.8.2011" "6.9.2011" "6.10.2011" "6.11.2011" "6.12.2011" "6.13.2011" [15] "6.14.2011" "6.15.2011" "6.16.2011" "6.17.2011" "6.18.2011" "6.19.2011" "6.20.2011" [22] "6.21.2011" "6.22.2011" "6.23.2011" "6.24.2011" "6.25.2011" "6.26.2011" "6.27.2011" [29] "6.28.2011" "6.29.2011" "6.30.2011" "6.31.2011" "6.32.2011" "6.33.2011" "6.34.2011" [36] "6.35.2011" "6.36.2011" "6.37.2011" "6.38.2011" "6.39.2011" "6.40.2011" "6.41.2011" [43] "6.42.2011" "6.43.2011" "6.44.2011" "6.45.2011" "6.46.2011" "6.47.2011" "6.48.2011" [50] "6.49.2011" "6.50.2011" "6.51.2011" "6.52.2011" "6.53.2011" > as.POSIXct(dates, format = "%w.%W.%Y") [1] "2011-01-01 EST" "2011-01-08 EST" "2011-01-15 EST" "2011-01-22 EST" "2011-01-29 EST" [6] "2011-02-05 EST" "2011-02-12 EST" "2011-02-19 EST" "2011-02-26 EST" "2011-03-05 EST" [11] "2011-03-12 EST" "2011-03-19 EDT" "2011-03-26 EDT" "2011-04-02 EDT" "2011-04-09 EDT" [16] "2011-04-16 EDT" "2011-04-23 EDT" "2011-04-30 EDT" "2011-05-07 EDT" "2011-05-14 EDT" [21] "2011-05-21 EDT" "2011-05-28 EDT" "2011-06-04 EDT" "2011-06-11 EDT" "2011-06-18 EDT" [26] "2011-06-25 EDT" "2011-07-02 EDT" "2011-07-09 EDT" "2011-07-16 EDT" "2011-07-23 EDT" [31] "2011-07-30 EDT" "2011-08-06 EDT" "2011-08-13 EDT" "2011-08-20 EDT" "2011-08-27 EDT" [36] "2011-09-03 EDT" "2011-09-10 EDT" "2011-09-17 EDT" "2011-09-24 EDT" "2011-10-01 EDT" [41] "2011-10-08 EDT" "2011-10-15 EDT" "2011-10-22 EDT" "2011-10-29 EDT" "2011-11-05 EDT" [46] "2011-11-12 EST" "2011-11-19 EST" "2011-11-26 EST" "2011-12-03 EST" "2011-12-10 EST" [51] "2011-12-17 EST" "2011-12-24 EST" "2011-12-31 EST" NA On Tue, Aug 16, 2011 at 4:01 AM, holdnatalie <osp...@bangor.ac.uk> wrote: > Hi, > > I would be very grateful for some advice. I have read the help pages for > Date, strptime, etc. All examples seem to use some version of day month year > as date format. However I have Weekly composite data so ONLY want to input > the dates as Week.Year (eg 35.2011). strptime seems to show this is possible > using %W for week (UK convention) and %Y for year. My data is in a df called > chlorophyll and has a date column. I tried to use the following (after I > converted to characters using as.character); > > chlorophyll$date <- strptime("chlorophyll$date", "%W.%Y") > > It recognised the year but replaced the week part with todays date (16TH > August). > > Any advice? > Thanks > Natalie > > -- > View this message in context: > http://r.789695.n4.nabble.com/Dates-week-and-year-not-day-tp3746591p3746591.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? ______________________________________________ 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.