I have two data.frames both include yearly data on some "ID" -lets say companies. df1 contains data on a national level for example information on the company's age. df2 contains data on state level for example revenue/customers/ etc. Here the example code:
states<-c("A","B","C")
x_values<-runif(6,1,100)
y_values<-runif(18,0,5)
df1<-data.frame("ID"=c(1,1,2,2,3,3),"Year"=rep(c(2000,2001),3),"X"=x_values)
df2<-data.frame("ID"=c(rep(1:3,each=3)),"Year"=rep(c(2000:2001),3,each=3),"State"=rep(states,2),"Y"=y_values)
From a statistical point of view is it feasible to merge these two data frames to one and simply repeat the "ID"& "Year" variables according to the number of observation in "Y"? Like so:
df3<-data.frame("ID"=c(rep(1:3,each=3)),"Year"=rep(c(2000:2001),3,each=3),"State"=rep(states,3),"X"=rep(x_values,each=3),"Y"=y_values)
Would this means I'd generally increase the number of rows in my data.frame by the multiple of states in the additional panel data I am merging? I need both types of information in my data/analysis.
Thanks a lot.