I have a list with multiple squared dataframes each representing the economy of a country. I would like to combine all the dataframes in a single dataframe with the data of each country on the diagonal cells corresponding to the same column and row names.
Here is a toy setup:
# toy IO
df1 <- data.frame (a1=rnorm(3),
b1=rnorm(3)+2,
c1=rnorm(3)*2)
rownames(df1) <- colnames(df1)
df2 <- data.frame (a2=rnorm(3),
b2=rnorm(3)+5,
c2=rnorm(3)*5)
rownames(df2) <- colnames(df2)
df3 <- data.frame (a3=rnorm(3),
b3=rnorm(3)+10,
c3=rnorm(3)*10)
rownames(df3) <- colnames(df3)
IO <- list(df1,df2,df3)
# initialize the MRIO
# 3*3=9
bigmat <- matrix(NA, 9,9)
dim(bigmat)
bigmat <- as.data.frame(bigmat)
# input row and col names
colnames(bigmat) <- c(colnames(df1),colnames(df2),colnames(df3))
rownames(bigmat) <- colnames(bigmat)
And here what I ideally want.