我遇到了一个问题,我遇到了以下代码:
#require(gdata)
require(jfreels)
require(mondate)
require(lubridate)
require(gdata)
# source this file
asof=as.Date('2017-05-31')
gm_quarter_value<-quarter(asof)
gm_year_value<-year(asof)
# load in and format data ----- the block of code where error occurs.
history_original<-
read.xls("//mhistory.xlsx",sheet='Allocation',na.strings="N/A")
mh<-data.table(history_original)
mh$date<-as.Date(mh$date)
setkey(mh,'date','mani')
mh[mani!='Cash',vami:=vami(return),by=fixed.name]
#load(file='data/history/mh.rda')
我试图通过在线阅读来修复错误,但似乎没有任何工作,因为所有解释都推断我正在创建数据表(dt。),而不是通过Excel文件导入数据表。
我的代码弹出的警告消息如下:
Warning messages:
1: In `[.data.table`(cgmh, strategy != "Cash", `:=`(vami, vami(return)), :
Supplied 145 items to be assigned to group 3 of size 146 in column 'vami' (recycled leaving remainder of 1 items).
2: In `[.data.table`(mh, mani != "Cash", `:=`(vami, vami(return)), :
Supplied 71 items to be assigned to group 21 of size 72 in column 'vami' (recycled leaving remainder of 1 items).
3: In `[.data.table`(mh, mani != "Cash", `:=`(vami, vami(return)), :
Supplied 44 items to be assigned to group 40 of size 45 in column 'vami' (recycled leaving remainder of 1 items).
4: In `[.data.table`(mh, mani!= "Cash", `:=`(vami, vami(return)), :
Supplied 27 items to be assigned to group 41 of size 28 in column 'vami' (recycled leaving remainder of 1 items).
以下是dput(head(mh,50))
中的一些数据structure(list(date = structure(c(12752, 12752, 12752, 12752,
12752, 12752, 12752, 12752, 12752, 12783, 12783, 12783, 12783,
12783, 12783, 12783, 12783, 12783, 12783, 12783, 12814, 12814,
12814, 12814, 12814, 12814, 12814, 12814, 12814, 12814, 12814,
12814, 12842, 12842, 12842, 12842, 12842, 12842, 12842, 12842,
12842, 12842, 12842, 12842, 12873, 12873, 12873, 12873, 12873,
12873), class = "Date"), fixed.name = structure(c(17L, 18L, 46L,
47L, 70L, 4L, 60L, 59L, 69L, 17L, 18L, 8L, 46L, 47L, 70L, 4L,
24L, 60L, 59L, 69L, 17L, 17L, 8L, 46L, 47L, 70L, 4L, 24L, 60L,
59L, 69L, 73L, 17L, 17L, 8L, 46L, 47L, 70L, 4L, 24L, 60L, 59L,
69L, 73L, 17L, 17L, 60L, 8L, 46L, 47L), .Label = c("1",
"2", "3", "4", "5", "6", "7", etc. class = "factor"),
manager = structure(c(24L, 44L, 62L, 70L, 71L, 5L, 43L, 85L,
99L, 24L, 44L, 12L, 62L, 70L, 71L, 5L, 32L, 43L, 85L, 99L,
24L, 27L, 12L, 62L, 70L, 71L, 7L, 32L, 43L, 85L, 101L, 107L,
24L, 27L, 12L, 62L, 70L, 71L, 7L, 32L, 43L, 85L, 101L, 107L,
24L, 27L, 43L, 12L, 62L, 70L), .Label = c(lots of data here ), class = "factor"), strategy = structure(c(1L,
1L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 1L, 1L, 2L, 2L, 2L, 2L, 4L,
4L, 4L, 4L, 4L, 1L, 1L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L,
4L, 1L, 1L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L,
1L, 2L, 2L, 2L), .Label = c("Cash", "Discretionary", "Quantitative",
"Trend Follower"), class = "factor"), gross_allocation = c(NA,
NA, 0.142404915838961, 0.0474683052796535, 0.0474683052796535,
0.189873221118614, 0.113923932671168, 0.261393169848591,
0.189873221118614, NA, NA, 0.0732346506007515, 0.127227083260399,
0.0504539213350938, 0.0500494951829262, 0.150598347942872,
0.097646200801002, 0.102648545851004, 0.139406844436169,
0.146469301201503, NA, NA, 0.0712445227169108, 0.123964691130067,
0.0476800374705463, 0.0485758686645857, 0.145697372074475,
0.0928750257506969, 0.0983016698067595, 0.13403145511268,
0.142043313516008, 0.0946955423440056, NA, NA, 0.0835168624939674,
0.106588512365316, 0.0643739492830623, 0.066140094839865,
0.120819106420193, 0.079432110728629, 0.0819557073526206,
0.11538840144924, 0.166281136586948, 0.127042633304666, NA,
NA, NA, 0.105856694204315, 0.106336463704097, 0.0628120217517739
), net_allocation = c(0, 0, 0.143494748241449, 0.0478315827471496,
0.0478315827471496, 0.191326330988599, 0.114795798593159,
0.263393625693896, 0.191326330988599, 0, 0, 0.0780974349815385,
0.135674967809812, 0.0538040641787497, 0.0533727841103034,
0.160598085609968, 0.104129913308718, 0.109464414314636,
0.148663465723197, 0.156194869963077, 0, 0, 0.0713080226118237,
0.124075180253433, 0.047722534454923, 0.0486191640989275,
0.145827231430156, 0.0929578048072517, 0.0983892856046405,
0.134150916693587, 0.142169916027154, 0.0947799440181028,
0, 0, 0.082564194313903, 0.10537266827038, 0.0636396423266499,
0.0653856416444407, 0.11944093541624, 0.0785260368878884,
0.0810208471071804, 0.114072177933095, 0.164384384924578,
0.125593471175645, 0, 0, NA, 0.0983666777386705, 0.0988125005761266,
0.0583676823484184), attribution = c(-0.000443266946085618,
0, 0.010051776300819, 0.00317113437469883, 0.00238472696113082,
0.00802893915484529, 0.00972706935855351, 0.00968370136548388,
0, -0.000440070107589608, 0.000121585143389376, 0.000229810333585158,
0.000600276113576124, -0.00128820140991525, 3.99695193738757e-05,
-0.000361129826732395, -0.00187724283985821, -0.00128385273636259,
-0.0011990465227359, 0, -0.00036254125256041, 0.000633512231325974,
-0.000512960563561758, -0.00347960664253897, 0.00141283713223096,
0.00251341429314942, -0.00912636717243622, -0.00308688292194134,
-0.00566091419913372, -0.00359918817341097, -0.0014308969925891,
0.00156261612460105, -0.000632849158692302, 2.08436840409153e-05,
0.00133540685104398, -0.000313375712697167, -0.00159815288576456,
-0.00473252239700671, -0.0113934901937967, 0.000777818917761139,
-0.0012305250368858, 0.00126422585853451, 0.00915133063638428,
0.00468022553426879, -0.000688569622908879, 0.00112718749151131,
NA, -0.000994649965118036, 0.00325597011568602, 0.00780374962611487
), cash_change = structure(c(2143L, 1161L, 1202L, 1967L,
1777L, 2512L, 1181L, 1178L, 1161L, 22L, 1771L, 2164L, 1294L,
496L, 2492L, 1000L, 686L, 493L, 460L, 1161L, 755L, 1348L,
47L, 995L, 1895L, 2235L, 338L, 942L, 92L, 1018L, 566L, 1960L,
802L, 2200L, 1936L, 1010L, 678L, 61L, 515L, 1589L, 550L,
1899L, 1693L, 1236L, 2100L, 1819L, 1L, 438L, 2460L, 1592L
), .Label = c("", "-0.179999999993015", "-0.309999999999945",
"-1", "-1.61999999999898", "-1.74622982740402e-010", "-100068.974874801",
"-100235.36", "-100276", "-100319", "-100330.48", "-100416.569999998",
"-100940.009999999", "-1014043.74000001", "-101446.620000001",
"-101573.619999999", "-101748.387580004", "-1018471.4", "-101919.760000002",
"-102261.04", "-102748.5", "-102775.78", "-103320.27", "-104101.220000001",
"-104371.649999999", "-104377.770000001", "-104541.310000001",
"-104628.85", "-104824.74", "-10491.2799999993", "-104981.119999999",
"-10503.46", "-1050639.386", "-105344.909999999", "-105556.61794",
"-105789.020000001", "-105974.700000001", "-106033.25", "-1064338.6",
"-106699.800000001", "-107116.92676", "-107245", "-107366.670000001",
"-1075850.947517", "-108219.72", "-10825.3", "-10833.8904",
"-1086.06", "-109098.68", "-109781", "-110030", "-110055.35",
"-110720.6", "-110939.54", "-111091.300000001", "-111159.81",
"-112.5", "-112523.399999999", "-112567.65", "-112924.3754",
"-112983.76", "-113459", "-11359.29", "-1137.7200000002",
"-113724.59", "-114064.922", "-114153.33", "-114339", "-1148311.78",
"-11499.2599999998", "-115498", "-115633.560000002", "-115669",
"-116181.349999999", "-116263.77", "-116345.49", "-116450.220000001",
"-1165174.434", "-116681.39", "-1169.39000000013", "-117.260000000359",
"-117.820000000007", "-117650.72", "-117976", "-118088.83",
"-118127", "-118366.880000001", "-118910.431612", "-11904.6899999995",
"-119076.620000001", "-119227.389999999", "-119560.31", "-119656",
"-119847.8272", "-12015", "-120228.99", "-121215.200000001",
"-12130.3399999999", "-121305.060000001", "-121359.48", "-121372",
"-12180.6916476834", "-121957.979999999", "-122016.87", "-122204",
"-122583.029999999", "-122763.76", "-12296.059", "-1231586.02",
"-12317.6600000001", "-123233.93", "-123985.18", "-12435.3400000001",
"-1243584.30698176", "-124386.42", "-124440.090000002", "-124663.23",
"-124749.83", "-124793.56", "-125286.95", "-125752.57", "-125991.149999999",
"-126087.13", "-126237.84", "-12664.3299999998", "-12678.8099999996",
"-127087.609999999", "-127365.219999999", "-127413.159999999",
"-127539", "-127599.52", "-127817", "-127918.43", "-128162.890000001",
"-128527.47", "-128537.842920001", "-12891.7100000009", "-1289347.356",
"-130006.02", "-1303381.25", "-13075.7300000004", "-132065.08",
"-132862", "-1332167", "-133229.1", "-133275.790000001",
"-133338.311793", "-133503.7", "-1335110.79028567", "-1337.90000000037",
"-13387.7999999998", "-133920.21", "-134013.22", "-13407",
"-134145.310000001", "-134485", "-134609", "-134663.096483",
"-134869.25", "-134924.48", "-13493", "-135069.81", "-13507.7385",
"-135282.92", "-135678", "-135838.550345", "-135966.47",
"-135980.300000001", "-136106.209999999", "-136170.24", "-136216.82",
"-13623.1699999999", "-136498.119999999", "-136566.42", "-13666.98",
"-13692.48", "-136986.177008999", "-137760.81", "-137788.919999999",
"-13814.404000001", "-138491.18", "-138764.109999999", "-139008.85",
"-139111.35", "-139225.75", "-14007.25", "-140087.68", "-140461",
"-140480.869999999", "-140559.73", "-140789.98", "-141094",
"-141172.939999999", "-141442.25", "-14176.7831290001", "-142115.64",
"-1422133.03", "-142394.86", "-14317.4900000002", "-143382.365999999",
"-143496.060000001", "-143889.82", "-144339.269999998", "-145025.73",
"-145032.54", "-145230.810000001", "-14555.0599999996", "-1463.14999999991",
"-1467083.61", "-147.699999999721", "-147371", "-1478130.07",
"-148036.200000003", "-1484752.36627733", "-148638", "-14909.0599999996",
"-1495.34999999963", "-149909.27", "-150808.970000001", "-151104",
"-151515", "-151554.5", "-151600.35", "-151761.93", "-152666.139999999",
"-1527.53999999957", "-153321.930489", "-153351.430000002",
"-153826.57", "-154261.23", "-154344.79", "-154366.819999998",
"-155071.159999999", "-1552270", "-155300.539999999", "-155664.83",
"-156528.430000002", "-157231.1", "-157309.49", "-157588.36",
"-157756.130000001", "-15811.5100000007", "-158116", "-158301.819999998",
"-15851.169999999", "-158916.79", "-15900.6599999992", "-159261.640000001",
"-159841.81", "-16028.8700000005", "-16041.0600000005", "-160788.28",
"-160931.31", "-161112.47", "-161391.54", "-161571.82", "-162772",
"-163080.23", "-1631776.18961502", "-16370.216", "-163878.1142",
"-16407.5000000009", "-164132.29", "-164310.990000002", "-16477.2000000002",
"-164922", "-1654145.89", "-16681.0199999996", "-166813.67",
"-167432", "-16806.3499999996", "-168587.42", "-168676.27",
"-168736.3815498", "-169282.720000001", "-169582.54", "-169808.25",
"-169880.369999999", "-17057.9499999993", "-171058.639999999",
"-17214.3399999999", "-172574", "-1727156.3", "-17324.3899999999",
"-1733011.377417", "-173827.036639996", "-173844.989699999",
"-174051.67", "-174113", "-174613.67", "-174662.9", "-175170.82",
"-175250.83", "-175571.09", "-176099.709999999", "-176272.018000001",
"-176316.539999999", "-176970.13", "-177463.85", "-177831.319999999",
"-178211.209999999", "-178706.12", "-179790.199999997", "-180461.18",
"-18086.96", "-18128.4466440002", "-181300.99", "-181974.76",
"-182119.993906", "-183227.55", "-18338", "-18377", "-184355.62",
"-184513.06", "-1851550.63567736", "-185359.37", "-186026.2",
"-18608.7799999993", "-18620.5700000003", "-186253.428",
"-186376", "-187126.5761172", "-187427", "-18747", "-18759.1000000006",
"-18766.4999999981", "-18767.1799999997", "-189286.97", "-1895.0700000003",
"-190057.699999999", "-190305.23", "-19074", "-190989.26",
"-191427.800000001", "-192097.08", "-192347.11", "-192681.0327519",
"-192751.78", "-193205.17", "-194234.0916", "-1943373.03",
"-194383", "-195419.41", "-19568.4000000004", "-196017.789999999",
"-196032.99", "-196138.35", "-196535.11", "-196541.58", "-196720",
"-196810.279999999", "-197097.19", "-197401.92", "-1982330.27000001",
"-19880", "-19903.3842000002", "-199137.73", "-199310.61",
"-200074.399999999", "-20135.3700000001", "-201950.129999999",...... NA,
NA, NA, 1.00175057961823, 1.07428786780012, 1.1734795592287
)), .Names = c("date", "name", "job", "mani",
"gross_allocation", "net_allocation", "attribution", "cash_change",
"return", "vami"), sorted = c("date", "strategy"), class = c("data.table",
"data.frame"), row.names = c(NA, -50L), .internal.selfref = <pointer: 0x0000000000120788>)
我对编码很新,并希望获得任何反馈,以帮助了解有关此警告的更多信息。是基础Excel工作表还是代码问题?