[R] Convert day of year back into a date format.

2012-03-27 Thread Sam Albers
Hello, I am having trouble figuring out how to convert a Day of Year integer back into a Date format. For example I have the following: date - c('2008-01-01','2008-01-02','2008-01-03','2008-01-04','2008-01-05','2008-01-06','2008-01-07',

Re: [R] Convert day of year back into a date format.

2012-03-27 Thread Justin Haynes
There may very well be a better solution, but this works. format(strptime(dayofyear, format=%j), format=%m-%d) On Tue, Mar 27, 2012 at 11:12 AM, Sam Albers tonightstheni...@gmail.comwrote: Hello, I am having trouble figuring out how to convert a Day of Year integer back into a Date format.

Re: [R] Convert day of year back into a date format.

2012-03-27 Thread Prof Brian Ripley
On 27/03/2012 19:30, Justin Haynes wrote: There may very well be a better solution, but this works. format(strptime(dayofyear, format=%j), format=%m-%d) The answer depends on the year (think leap years), so I think you need strptime(paste(2008, dayofyear), format=%Y %j) Probably a better