R: How to get a date from day of year
I am working with a data set that looks a bit like this:
Year Date Day_nr Value
1976 19-02-1976 50 167
1976 19-03-1976 79 140
1978 05-03-1978 64 200
1978 05-04-1978 95 200
1999 05-05-1999 125 89
1999 20-06-1999 171 79
I am then interested to estimate a polynomial model for each year
depending on the day number as a x value. I then run a predict function to
estimate the values of the model. I do that with the day numbers. My Data
for the predict data frame then looks a bit like this just with more
entries per year
Year Day_nr Value
1976 53 167
1976 80 140
1978 69 300
1978 130 200
1999 140 89
1999 160 79
What I now would like to do is get a date out of these day numbers and the
year. I thought I could do it with lubridate but I could only find the
opposite direction which I use to generate the day numbers in the first
place in the original data file. Working with the whole date as a
predictor is not possible for me as I need the day number for other
calculations.
Is there a way to easily do that?
Cheers, Sarina
No comments:
Post a Comment