I have a dataset like countries_not_appear_indices
countries_not_appear_indices <- as.data.frame(c("CUW", "ARM", "VGB", "ATG", "KNA", "GRD", "VCT", "LCA", "TCA", "GNB", "GNQ", "CYM", "MNE", "MDV", "MKD", "GIB", "LIE", "COM", "NCL", "BES", "PYF")) %>%
rename(iso = `c("CUW", "ARM", "VGB", "ATG", "KNA", "GRD", "VCT", "LCA", "TCA", "GNB", "GNQ", "CYM", "MNE", "MDV", "MKD", "GIB", "LIE", "COM", "NCL", "BES", "PYF")`) %>%
mutate(ie = 0, ih = 0)
and I want to repeat each observation 11 times (one time for each month). So we have something like countries_not_appear_indices_panel
iso <- c("CUW", "CUW", "CUW", "CUW", "CUW", "CUW", "CUW", "CUW", "CUW", "CUW", "CUW", "CUW", "ARM", "ARM", "ARM", "ARM", "ARM", "ARM", "ARM", "ARM", "ARM", "ARM", "ARM", "ARM")
month <- c(1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12)
ie <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
ih <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
countries_not_appear_indices_panel <- data.frame(iso, month, ie, ih)
To repeat each column I did try:
countries_not_appear_indices[rep(seq_len(nrow(countries_not_appear_indices)), each = 12), ]
However, I also have to generate the month function in the correct way.
Any clue?