How to convert monthly data into daily data

This is one way

library(tidyverse)
library(lubridate)
df <- tribble(~TIME,~inflation_US,~inflation_IN,
"2011-01",	1.631847,	9.302325,
"2011-02",	2.107585,	8.823529,
"2011-03",	2.681603,	8.823529,
"2011-04",	3.163631,	9.411765,
"2011-05",	3.568646,	8.72093,
"2011-06",	3.558828,	8.620689)

base_df <- df %>% mutate(dt=lubridate::ymd(paste0(TIME,"-01"))) 
all_dates <- base_df %>%select(dt) %>% 
  complete(dt=  seq.Date(min(dt), max(dt), by="day"),
           ) %>% mutate(TIME=paste(year(dt),str_pad(month(dt), 2, pad = "0"),sep = "-"))

left_join(all_dates,df,by="TIME")
1 Like