[R] Convert day of year back into a date format.
tonightsthenight at gmail.com
Tue Mar 27 20:12:48 CEST 2012
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',
## this is then converted into a number corresponding to the day of
the year like so:
dayofyear <- strptime(date, format="%Y-%m-%d")$yday + 1
## Now my question is how do I get back to a date format (obviously
omitting the year).
## The end result is that I'd like to be able to have axis labels as
something like "Month-Day" or just "Month"
## instead of just an integers which isn't always intuitive for people
but I can't seem to figure out how to tell R
## to recognize an integer as a date.
Many thanks in advance!
More information about the R-help