Hello,
I am trying to create time-dependent variables, but I am struggling with the code to structure them.
As you can see in the reproducible example, I have several bills in four countries, but each of them has a different length - because of the legislative procedures. Therefore, some start and finish in the same year, while others continue for a long period of time.
For the GDP growth, I have yearly measurements and I would like to specify it for each bill/country/year.
mydata<-data.frame(
stringsAsFactors = FALSE,
bill = c("Protocolo de Asuncion para Derechos Humanos",
"Protocolo de Asuncion para Derechos Humanos","Protocolo de Asuncion para Derechos Humanos",
"Protocolo de Asuncion para Derechos Humanos"),
country = c("Argentina", "Brazil", "Paraguay", "Uruguay"),
dateentr = c("2006-03-22", "2006-10-17", "2006-03-29", "2006-06-09"),
dateappr = c("2006-06-07", "2009-08-25", "2006-09-26", "2008-05-07"),
cause = c(1L, 1L, 1L, 1L)
)
gdpgrowth_long<-data.frame(
stringsAsFactors = FALSE,
year = c("2006","2006","2006","2006",
"2006","2006","2007","2007","2007","2007","2007",
"2007","2008","2008","2008","2008","2008","2008",
"2009","2009","2009","2009","2009","2009"),
country = c("Argentina","Brazil",
"Paraguay","Uruguay","...6","...7","Argentina","Brazil",
"Paraguay","Uruguay","...6","...7","Argentina","Brazil",
"Paraguay","Uruguay","...6","...7","Argentina",
"Brazil","Paraguay","Uruguay","...6","...7"),
gdpgrowth = c(8.04715150365762,
3.96198872336626,4.80711719270674,4.09857734684473,NA,NA,
9.00765087916513,6.06987060717197,5.42162287220238,
6.5415108494737,NA,NA,4.05723310237891,5.09419544721958,
6.35912079324652,7.17614466103376,NA,NA,-5.91852508035113,
-0.125811999603498,-0.257971433717119,4.24349419543073,
NA,NA)
)
I appreciate your help!