我有12个月的库存数据包含在12个数据框的列表中。每个数据框具有以下结构:
'data.frame': 218680 obs. of 19 variables:
$ Symbol : Factor w/ 3423 levels "AABC","AACB",..: 1 1 1 1 1 1 1 1 1 1 ...
$ MktCategory : Factor w/ 4 levels " NR - Non-Market Maker Reporting Member",..: 4 4 4 4 4 4 4 4 4 4 ...
$ TSO : Factor w/ 3352 levels ""," C - ECN",..: 745 745 745 745 745 745 745 745 745 745 ...
$ TSO_Date : Factor w/ 180 levels "","01/12/2005",..: 159 159 159 159 159 159 159 159 159 159 ...
$ X.OfMP : int 4 4 4 4 4 4 4 4 4 4 ...
$ MPID : Factor w/ 739 levels "","ABLE","ABNA",..: 590 668 292 306 313 587 100 681 432 598 ...
$ MP_type : Factor w/ 4 levels "","C","M","NR": 3 2 3 3 3 3 2 4 3 3 ...
$ Total_Vol : int 0 0 0 0 60000 0 300 2184 0 0 ...
$ Total_Rank : int 0 0 0 0 1 0 4 3 0 0 ...
$ Total_Pct : int 0 0 0 0 92 0 0 3 0 0 ...
$ Block_Vol : int 0 0 0 0 55000 0 0 0 0 0 ...
$ Block_Rank : int 0 0 0 0 1 0 0 0 0 0 ...
$ Block_Pct : int 0 0 0 0 100 0 0 0 0 0 ...
$ YTD_Total_Vol : int 100 900 100 2200 124541 18429 10700 7732 13600 200 ...
$ YTD_Total_Rank: int 16 10 16 9 1 3 5 6 4 14 ...
$ YTD_Total_Pct : int 0 0 0 0 54 8 5 3 6 0 ...
$ YTD_Block_Vol : int 0 0 0 0 117500 0 0 0 0 0 ...
$ YTD_Block_Rank: int 0 0 0 0 1 0 0 0 0 0 ...
$ YTD_Block_Pct : int 0 0 0 0 100 0 0 0 0 0 ...
我希望将所有数据框合并到一个数据框中,其中每个数据框列出第一列,其余列只是与各个月的符号相关联的Total_Vol和Total_Rank。有点像这样:
符号Total_Vol(month1)总排名(第1个月)Total_Vol(month2)Total_Rank(month2)...
AACC ...
AACE ....
AAON ...
AAPL
AATI
AAUK
ABAX
ABCB
ABCO
ABCW
答案 0 :(得分:0)
这应该可行。
install.packages('plyr')
library(plyr)
df_list <- list(df_1[c('Symbol','Total_vol','Total_rank')],
df_2[c('Symbol','Total_vol','Total_rank')],
df_3[c('Symbol','Total_vol','Total_rank')])
join_all(df_list, by = 'Symbol')