Merge Panel data to get balanced panel data

There’s a function for that. Combine the data frames with rbind. Then use complete. It will look through the groups in variable and fill any with missing values: library(tidyr) df3 <- do.call(rbind.data.frame, list(df1, df2)) df3$Month <- as.character(df3$Month) df4 <- complete(df3, Month, variable) df4$Month <- as.yearmon(df4$Month, “%b %Y”) df5 <- df4[order(df4$variable,df4$Month),] df5 # Source: local data … Read more