Manipulating a Dataframe with vectors inside the dataframe

have a dataframe of 55 rows x 556 columns witch each "case" of the matrix having a vector of six factors named: SMB,HML,UME.PROXY,RMW,CMA,MKT.NEW As you can see in the following screenshot.

  1. I need to average each Factor by column.

for example take all the values of the"UME.PROXY" coefficient of each vector in column one and average these values to end up with only one value (which is the average) for "UME.PROXY" for that column.

So at the end I would like to end up with a matrix lets call it matrix B of 1 row x 55 columns with each column having a vector of 6 coefficients corresponding to the average of the column for each factor.

  1. After that once I have that matrix I would eventually like to transform matrix B into matrix C to have 6 rows(one for each factor) per column (instead of a vector of 6 factors per column) so ending up with a Matrix C with 6 rows x 556 columns.

I hope it is clear and I would like to help you in advance for your help.

Here is the dput if it helps

Blockquote

dput(head(DF[10:10]))
structure(list(list(c(UME.PROXY = -1.46792406584093, SMB = -0.335928643143305,
HML = 0.078951132459234, RMW = 0.0360759262269553, CMA = -0.147408484603944,
MKT.New = 1.06013154345764), c(UME.PROXY = -1.47200056370772,
SMB = -0.334924606368284, HML = 0.0315390552970403, RMW = -0.0486185515370473,
CMA = -0.167573111918424, MKT.New = 1.05060486022485), c(UME.PROXY = -1.17480519297791,
SMB = -0.224179562220809, HML = 0.0528513748129118, RMW = 0.0309448561191931,
CMA = -0.182903201492864, MKT.New = 1.0573908044982), c(UME.PROXY = -1.49487748414678,
SMB = -0.165851083093961, HML = 0.0499189826247655, RMW = 0.0407614788042679,
CMA = -0.252505867514034, MKT.New = 0.984472836436174), c(UME.PROXY = -1.50422741241686,
SMB = -0.174696974583352, HML = 0.0603046276438098, RMW = 0.0574529773429186,
CMA = -0.255237723903091, MKT.New = 0.98208970318243), c(UME.PROXY = -1.50530479112584,
SMB = -0.185226104674429, HML = 0.0215883125577546, RMW = 0.00313504487143439,
CMA = -0.249274823685661, MKT.New = 0.98114333692362))), row.names = c(NA,
6L), class = "data.frame")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.