1
I have the following situation :
all_sec = Matrix of all possible assets in a portfolio
all_sec <- matrix(c("SEC1","SEC2","SEC3","SEC4","SEC5"),ncol=1)
portfolio <- composition of a portfolio of assets (column 2 is equal to the weight of the asset in the portfolio
portfolio <- matrix(c("SEC2","SEC4",0.45,0.55),ncol=2)
I want as a result a 1 column Matrix in which the value returns 0 if the asset is not in the portfolio and returns the weight value (column 2 of the portfolio matrix) if it is in the portfolio. The result would be a Matrix in this format :
[,1]
[1,] 0
[2,] 0.45
[3,] 0
[4,] 0.55
[5,] 0
Could you help me ?