R studio date fill in dataframe -
i have dataframe values , date, have projection values historical averages.
my question is, how fill in date column sequential dates fit current dataframe row number if remainder of dates na (my dates range 2017-07-14 2017-09-11, , dataframe several rows longer).
see simplified example below:
day <- as.date(c("2017-01-01","2017-01-02","2017-01-03", na, na )) value <- c(1, 2, 3, 4, 5) df <- as.data.frame(day) df$value <- value
requirement extrapolate dates value 4 , 5 using last date available.
cheers,
df <- data.frame(date = as.date(c("2017-01-01", "2017-01-02" "2017-01-03", na, na)), value = 1:5) df$date <- seq.date(from = df$date[1], length.out = dim(df)[1], = "day")
see ?seq.date
details, hope helps.
Comments
Post a Comment