Take a data frame that looks like this and contains data for some dates in 2005 and a measurement at each date.
df <- data.frame("date" = c('2005-04-04','2005-04-19', '2005-04-26', '2005-05-05',
'2005-05-12', '2005-05-25', '2005-06-02', '2005-06-16', '2005-07-07', '2005-07-14',
'2005-07-21', '2005-08-04'), "numbers" = c(90,50,50,48,44,37,34,30,36,31,49,54))
I want to create a sequence of values from 1:365 based on this for each day of the year, essentially to create a new data frame from 01/01/2005 to 31/12/2005 which has been infilled with the values from a spline function fitting over these existing 12 values.
When I try to do this using:
numbers <- df$numbers
x = spline(1:365, numbers)
I get
Error in xy.coords(x, y, setLab = FALSE) : 'x' and 'y' lengths differ'
I'm not sure what is going wrong.