0

i have a Dataset-Matrix called Sigma_ma including Monthly Data from 30 european banks. Now i have to check the connectedness between different pairs. Therefore my plan is to use cbind to create a new matrix, including the Data of some Banks. My Code:

Sigma_ma_bank_size <- cbind(Sigma_ma[,"HSBA.L"],Sigma_ma[,"BNPP.PA"],Sigma_ma[,"DBKGn.DE"],Sigma_ma[,"SAN.MC"],Sigma_ma[,"INGA.AS"],Sigma_ma[,"ISP.MI"]
                            ,Sigma_ma[,"UBSG.S"],Sigma_ma[,"RBS.L"],Sigma_ma[,"NDASE.ST"],Sigma_ma[,"KBC.BR"],Sigma_ma[,"DNB.OL"],Sigma_ma[,"SEBa.ST"]
                            ,Sigma_ma[,"ERST.VI"],Sigma_ma[,"PEO.WA"],Sigma_ma[,"BIRG.I"],Sigma_ma[,"DANSKE.CO"])

The Result is (shortened):

         V1         V2
 7.010374e-05 1.117888e-04
 4.271750e-05 1.207572e-04

how do I get the right name for the columns? V1 -> HSBA.L V2 -> BNPP.PA

thank you very much

StSZ
  • 29
  • 1
  • 5
  • colnames(Sigma_ma_bank_size) <- c('HSBA.L V2','BNPP.PA') – Eric Dec 11 '19 at 16:10
  • Duplicate of [How does one reorder columns in a data frame?](https://stackoverflow.com/questions/5620885/how-does-one-reorder-columns-in-a-data-frame) – M-- Dec 11 '19 at 16:24

2 Answers2

4

All your columns come from the same source. Instead of using cbind, simply use [ to subset instead with a vector of the columns you want:

Sigma_ma_bank_size <- Sigma_ma[,c("HSBA.L","BNPP.PA","DBKGn.DE","SAN.MC","INGA.AS","ISP.MI"
                            ,"UBSG.S","RBS.L","NDASE.ST","KBC.BR","DNB.OL","SEBa.ST"
                            ,"ERST.VI","PEO.WA","BIRG.I","DANSKE.CO")]
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
0
V1<-runif(2)
V2<-runif(2)



 Sigma_ma_bank_size<-matrix(V1,V2,nrow = 2,ncol = 2)

colnames(Sigma_ma_bank_size)<-c("V1","V2")

I' am assuming that after you do the cbind your data looks like the following

           V1        V2
[1,] 0.550721 0.1290283
[2,] 0.550721 0.1290283    

you can then use the colnames to rename the columns based on the names of the Bank

colnames(Sigma_ma_bank_size)<-c('HSBA.L','BNPP.PA')

       HSBA.L   BNPP.PA
[1,] 0.550721 0.1290283
[2,] 0.550721 0.1290283
Nathan123
  • 763
  • 5
  • 18