首页 > 解决方案 > R中列表列表中只有一列的bind_cols

问题描述

我正在尝试使用map_dfr从我的列表中提取和加入单个列。在lst2我的每个列表中都有一个名为date. 我想提取它并将其与lst1. 以下不起作用map_dfr(lst1, lst2, bind_cols),我实际上只想绑定datelst2并忽略其余部分。

预期的输出将是datefromlst2添加到 中的每个列表列表中lst1。中的每个列表列表中的date列略有不同lst2

资料清单一:

    lst1 <- list(`5` = list(`2016-01-01` = structure(list(holiday = c(-0.287505149841309, 
-0.261321395635605, -0.27884966135025, -0.285283505916595, -0.282738029956818, 
-0.279988586902618), temp = c(-0.00413159467279911, 0.075470507144928, 
0.14860537648201, -0.0112847499549389, 0.0126002347096801, 0.0553472861647606
), wind = c(-0.689423203468323, 0.158847570419312, 0.847523272037506, 
0.111226610839367, -0.089162141084671, -0.29320240020752), humidity = c(0.0878895819187164, 
0.115549802780151, 0.0808247774839401, 0.13438692688942, 0.168190106749535, 
0.0706237256526947), barometer = c(-0.0442701764404774, -0.0273909661918879, 
-0.110819362103939, -0.0135176228359342, 0.017435971647501, -0.00947459880262613
), weekday = c(0.081529937684536, 0.111831456422806, 0.0768596306443214, 
0.0925759300589561, 0.0789813026785851, 0.086820051074028), weekend = c(0, 
0, 0, 0, 0, 0), workday_on_holiday = c(-0.00449116015806794, 
-0.00492851622402668, -0.00990568101406097, -0.00535996304824948, 
-0.00591197935864329, -0.00449116015806794), weekend_on_holiday = c(0, 
0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(0.0545360967516899, 
0.070147879421711, 0.0239687878638506, 0.0693793371319771, 0.0703154131770134, 
0.0456382371485233), text_light_rain = c(0.0205550380051136, 
0.0347262620925903, 0.0337300077080727, 0.0276936888694763, 0.0274705961346626, 
0.0205550380051136), text_mostly_cloudy = c(-0.0035081070382148, 
-0.0106095243245363, -0.00892648566514254, 0.00776881678029895, 
-0.0245751272886992, -0.0141745395958424), text_passing_clouds = c(0.0114779146388173, 
0.0142141683027148, 0.00865811575204134, 0.0236570592969656, 
0.0147861018776894, 0.014693571254611), text_rain = c(0.0248998813331127, 
-0.000406149541959167, -0.032954890280962, -0.000589479866903275, 
0.00113414553925395, -0.000406149541959167), text_scattered_clouds = c(-0.0810607820749283, 
-0.0777786746621132, -0.172431215643883, -0.0851063579320908, 
-0.0796751528978348, -0.0967930480837822), text_sunny = c(0.00860885996371508, 
0.00318501936271787, 0.00632673315703869, 0.00091076479293406, 
0.00572518166154623, 0.0106474123895168), month_1 = c(0.0764073804020882, 
0.163439929485321, 0.0846812948584557, 0.157616153359413, 0.0762593746185303, 
0.0853563472628593), month_2 = c(0.0455782376229763, 0.0182493720203638, 
0.0024642909411341, 0.0399442575871944, 0.0477627664804459, 0.0225149858742952
), month_3 = c(0.00336221815086901, 0.00445762183517218, -0.0292761437594891, 
-0.000451473635621369, 0.0162581335753202, 0.00577702885493636
), month_4 = c(-0.0627421438694, -0.173753097653389, -0.0831228122115135, 
-0.159142002463341, -0.144872710108757, -0.132649913430214), 
    month_5 = c(-0.0746728777885437, -0.147042363882065, -0.0870080813765526, 
    -0.154210984706879, -0.0838618874549866, -0.105986662209034
    ), month_6 = c(-0.032955776900053, -0.00787918921560049, 
    -0.00770710874348879, -0.00865088775753975, -0.0083921467885375, 
    -0.0374950207769871), month_7 = c(-0.0100117931142449, -0.0129543459042907, 
    -0.0147038688883185, -0.0122463470324874, -0.0122463470324874, 
    -0.0128087708726525), month_8 = c(-0.0355697833001614, -0.0451076440513134, 
    -0.0443550981581211, -0.0451076440513134, -0.0451076440513134, 
    -0.036579642444849), month_9 = c(0.0187235474586487, 0.0188821014016867, 
    0.0159602463245392, 0.0188821014016867, 0.0190539490431547, 
    0.0190539490431547), month_10 = c(0.071361169219017, 0.0771452113986015, 
    0.0575473643839359, 0.076715886592865, 0.0704263001680374, 
    0.0722210109233856), month_11 = c(0.0580858998000622, 0.0873404517769814, 
    0.057171318680048, 0.0863843932747841, 0.110879138112068, 
    0.0858354195952415), month_12 = c(0.15059332549572, 0.250447928905487, 
    0.0866759195923805, 0.179991602897644, 0.115858882665634, 
    0.179295092821121)), row.names = c(NA, 6L), class = "data.frame"), 
    `2016-01-02` = structure(list(holiday = c(-0.272332519292831, 
    -0.340749680995941, -0.29936483502388, -0.262564092874527, 
    -0.244395390152931, -0.24520780146122), temp = c(0.134692505002022, 
    0.111628539860249, 0.0722469985485077, 0.0883198082447052, 
    0.0662637650966644, 0.0605684258043766), wind = c(0.143159076571465, 
    0.776454508304596, 0.118829421699047, -0.0511538982391357, 
    -0.242683932185173, -0.280367434024811), humidity = c(0.129436731338501, 
    0.0423655584454536, 0.0963118970394135, 0.143828451633453, 
    0.0356308110058308, 0.125916793942451), barometer = c(-0.035864919424057, 
    -0.0873878672719002, -0.0221946015954018, -0.00450283708050847, 
    -0.00959178991615772, 0.0137610333040357), weekday = c(0.114081330597401, 
    0.0863068029284477, 0.0976831987500191, 0.0876984223723412, 
    0.0789007022976875, 0.0907445028424263), weekend = c(0, 0, 
    0, 0, 0, 0), workday_on_holiday = c(-0.00402905605733395, 
    -0.00453507993370295, -0.00482375361025333, -0.00508680287748575, 
    -0.00402905605733395, -0.00376600702293217), weekend_on_holiday = c(0, 
    0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(0.11833580583334, 
    0.0388534627854824, 0.115720294415951, 0.120073936879635, 
    0.0912353321909904, 0.0499505363404751), text_light_rain = c(0.0520697049796581, 
    0.0487560331821442, 0.0497864708304405, 0.0607201047241688, 
    0.0531328953802586, 0.050849661231041), text_mostly_cloudy = c(-0.0203497968614101, 
    -0.0203211829066277, -0.0203497968614101, -0.0237297993153334, 
    -0.0105950376018882, -0.0152477817609906), text_passing_clouds = c(0.00878167618066072, 
    0.000530663761310279, 0.0143402041867375, 0.0136684160679579, 
    0.00791957695037127, 0.00819030683487654), text_rain = c(-0.00133128161542118, 
    -0.0482824929058552, -0.0013865182409063, 0.000755225541070104, 
    -0.0013865182409063, -0.0013865182409063), text_scattered_clouds = c(-0.0839326903223991, 
    -0.166067808866501, -0.104155018925667, -0.0906047150492668, 
    -0.109635159373283, -0.0941797941923141), text_sunny = c(0.00581001630052924, 
    0.00568450707942247, 0.00266551366075873, 0.0067223091609776, 
    0.0134993428364396, 0.0094219297170639), month_1 = c(0.109191954135895, 
    0.0550585612654686, 0.123545065522194, 0.0814228802919388, 
    0.0547124668955803, 0.0466522350907326), month_2 = c(0.00459166103973985, 
    0.00601228745654225, 0.0340671129524708, 0.0411521792411804, 
    0.015175917185843, -0.00683757895603776), month_3 = c(0.00803727563470602, 
    -0.0509188324213028, 0.00803727563470602, 0.00101890868972987, 
    -0.000487668992718682, 0.00101890868972987), month_4 = c(-0.172974124550819, 
    -0.14289490878582, -0.172974124550819, -0.174231216311455, 
    -0.179455310106277, -0.174041390419006), month_5 = c(-0.114909239113331, 
    -0.0815929844975471, -0.114909239113331, -0.0847142040729523, 
    -0.119625508785248, -0.0925337672233582), month_6 = c(-0.0256863348186016, 
    -0.0171801336109638, -0.0256863348186016, -0.0254424661397934, 
    -0.0288356766104698, -0.0256347432732582), month_7 = c(-0.00124008720740676, 
    -0.000914117030333728, -0.00219869031570852, -0.00219869031570852, 
    0.00217337417416275, 0.00217337417416275), month_8 = c(-0.0525347702205181, 
    -0.0453627146780491, -0.0501848794519901, -0.05464031919837, 
    -0.0498320944607258, -0.047506932169199), month_9 = c(0.0249587465077639, 
    0.0150943985208869, 0.026452062651515, 0.0224876832216978, 
    0.021443136036396, 0.021443136036396), month_10 = c(0.0767439901828766, 
    0.0637840330600739, 0.076332226395607, 0.0759803578257561, 
    0.0758688449859619, 0.0741193741559982), month_11 = c(0.0604153387248516, 
    0.0535821802914143, 0.047236505895853, 0.129973396658897, 
    0.0794788673520088, 0.0823308974504471), month_12 = c(0.260544240474701, 
    0.104838013648987, 0.194464340806007, 0.136765509843826, 
    0.1962860673666, 0.228263437747955)), row.names = c(NA, 6L
    ), class = "data.frame")), `6` = list(`2016-01-01` = structure(list(
    holiday = c(-0.01831397973001, -0.0278525706380606, -0.0545091107487679, 
    -0.0852110907435417, -0.0915239304304123, -0.0201904978603125
    ), temp = c(0.0619977787137032, 0.240116253495216, 0.30674609541893, 
    0.0303262006491423, -0.0750823989510536, 0.0211294107139111
    ), wind = c(-0.980749845504761, 0.299531370401382, 0.994995355606079, 
    0.362696558237076, 0.219618409872055, -0.307217717170715), 
    humidity = c(0.0190069638192654, 0.0383657030761242, -0.0103078661486506, 
    0.386975973844528, 0.0216114148497581, 0.0369361937046051
    ), barometer = c(-0.0764741972088814, -0.0111954780295491, 
    -0.132382750511169, 0.0809806659817696, 0.282660692930222, 
    0.0890090838074684), weekday = c(0.0523185282945633, 0.0715024098753929, 
    0.10260059684515, 0.0199155658483505, 0.0760686323046684, 
    0.0664166510105133), weekend = c(0, 0, 0, 0, 0, 0), workday_on_holiday = c(-0.00574090098962188, 
    -0.0297964438796043, -0.027728658169508, -0.107685536146164, 
    -0.110589444637299, -0.0184716582298279), weekend_on_holiday = c(0, 
    0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(0.0996797382831573, 
    0.106587544083595, 0.115442782640457, 0.0638781487941742, 
    0.0548176616430283, 0.102432563900948), text_light_rain = c(0.000621219805907458, 
    0.000409607600886375, -0.0062907743267715, 0.00471668830141425, 
    0.0146307684481144, 0.00518008414655924), text_mostly_cloudy = c(-0.1487677693367, 
    -0.130784466862679, -0.150917783379555, -0.151641234755516, 
    -0.0495412796735764, -0.129829555749893), text_passing_clouds = c(0.0073356693610549, 
    0.0170528776943684, -0.00333861657418311, 0.0242675002664328, 
    0.00929313059896231, 0.00433033425360918), text_rain = c(0.00624925876036286, 
    0.0306352786719799, 0.031936164945364, 0.0310601592063904, 
    0.0337994284927845, 0.0347826145589352), text_scattered_clouds = c(-0.0313251540064812, 
    -0.00891299080103636, -0.0361328050494194, -0.0527477525174618, 
    0.00748181901872158, -0.0359514877200127), text_sunny = c(0.00310508860275149, 
    0.00278438744135201, 0.00266698561608791, 0.00256888521835208, 
    0.0030412464402616, 0.00211086357012391), month_1 = c(0.0124078718945384, 
    0.115149907767773, 0.0342674888670444, 0.0768248960375786, 
    0.0654645636677742, 0.0636573806405067), month_2 = c(0.00906078889966011, 
    0.00684765540063381, 0.00684765540063381, 0.0043728593736887, 
    0.00523211201652884, 0.00523211201652884), month_3 = c(-0.00860895030200481, 
    0.0395329669117928, -0.00739339413121343, 0.0254243556410074, 
    0.0387462340295315, 0.000762063078582287), month_4 = c(0.0156710669398308, 
    -0.0731847062706947, -0.059317272156477, -0.0797693580389023, 
    -0.063595674932003, -0.0707821249961853), month_5 = c(0.0155536076053977, 
    -0.00135426537599415, -0.000712861423380673, 0.00186582200694829, 
    0.00462800171226263, 0.00815873499959707), month_6 = c(-0.00416068313643336, 
    -0.00582700222730637, -0.00630857422947884, -0.00630857422947884, 
    -0.00371318752877414, -0.0028462684713304), month_7 = c(-0.0765896588563919, 
    -0.0602815672755241, -0.0606993623077869, -0.0679243355989456, 
    -0.0981804504990578, -0.143634766340256), month_8 = c(-0.0274758692830801, 
    -0.029958751052618, -0.0222828015685081, -0.0231222733855247, 
    -0.0426335595548153, -0.0394838415086269), month_9 = c(0.0263891816139221, 
    0.0408347435295582, 0.0264717359095812, 0.0400248542428017, 
    0.0434771627187729, 0.0341347306966782), month_10 = c(0.0503858253359795, 
    0.0485818050801754, 0.0558837354183197, 0.0611822977662086, 
    0.056214764714241, 0.0590351931750774), month_11 = c(0.0138247236609459, 
    0.0193855240941048, 0.0193508081138134, 0.0653398260474205, 
    0.0657737776637077, 0.0138247236609459), month_12 = c(0.0957958102226257, 
    0.135555163025856, 0.124385118484497, 0.165062874555588, 
    0.177980005741119, 0.212877199053764)), row.names = c(NA, 
6L), class = "data.frame"), `2016-01-02` = structure(list(holiday = c(-0.0269235819578171, 
-0.0375330299139023, -0.150185480713844, -0.180965185165405, 
-0.0315828360617161, -0.0701441094279289), temp = c(0.243527591228485, 
0.371963232755661, 0.0472849868237972, -0.0628702938556671, 0.0950800850987434, 
0.0399793609976768), wind = c(0.312333345413208, 1.05714356899261, 
0.438581466674805, 0.249333217740059, -0.289588332176208, -0.241006031632423
), humidity = c(0.122070841491222, 0.0394690744578838, 0.30509290099144, 
0.145370110869408, 0.127359732985497, 0.120208732783794), barometer = c(-0.00119671260472387, 
-0.141092225909233, 0.165500268340111, 0.272881299257278, 0.180314168334007, 
0.366155594587326), weekday = c(0.0754338949918747, 0.102761223912239, 
0.0114814033731818, 0.0844534561038017, 0.0735206827521324, 0.0815589874982834
), weekend = c(0, 0, 0, 0, 0, 0), workday_on_holiday = c(-0.00934421829879284, 
-0.0113556934520602, -0.0479315407574177, -0.0799224302172661, 
-0.00402316637337208, -0.00376265193335712), weekend_on_holiday = c(0, 
0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(0.121573232114315, 
0.142543613910675, 0.0842383652925491, 0.0666860789060593, 0.118839487433434, 
0.0962422415614128), text_light_rain = c(-0.00105138635262847, 
-0.00085716979810968, -0.00249776896089315, -0.00258254911750555, 
-0.00207408331334591, -0.00207408331334591), text_mostly_cloudy = c(-0.102763526141644, 
-0.145860776305199, -0.17062683403492, -0.107765935361385, -0.0928198248147964, 
-0.0847341865301132), text_passing_clouds = c(0.00650645792484283, 
-0.0119929825887084, 0.00129361264407635, 0.00169141637161374, 
0.00034726966987364, 0.000147873506648466), text_rain = c(0.0432413183152676, 
0.0620547793805599, 0.0612813010811806, 0.0676166415214539, 0.067610040307045, 
0.0667802914977074), text_scattered_clouds = c(0.00680965557694435, 
-0.0301695875823498, -0.0163288377225399, 0.00500796362757683, 
-0.013679507188499, -0.0105399489402771), text_sunny = c(0.00175180716905743, 
0.0044323937036097, 0.00130739971064031, -0.000148897292092443, 
0.000350211892509833, 0.00125334970653057), month_1 = c(0.13130210340023, 
0.0630867704749107, 0.140457063913345, 0.141706764698029, 0.0985265597701073, 
0.0603985860943794), month_2 = c(-0.00919519551098347, 0.0138415843248367, 
0.0109194563701749, 0.0105534996837378, 0.0103707788512111, 0.0100245578214526
), month_3 = c(0.0568007789552212, -0.0135478051379323, 0.000756092253141105, 
0.00378916412591934, -0.0378580540418625, -0.0227362904697657
), month_4 = c(-0.0758921280503273, -0.0510909892618656, -0.0998639911413193, 
-0.0716328546404839, -0.0660951882600784, -0.0549110621213913
), month_5 = c(0.000941433012485504, 0.000817757972981781, 0.0000343952524417546, 
0.0000343952524417546, 0.000308761722408235, 0.000308761722408235
), month_6 = c(-0.0190888661891222, -0.0180853568017483, -0.0180853568017483, 
-0.0131239648908377, -0.0131239648908377, -0.0192493200302124
), month_7 = c(-0.0366223938763142, -0.033847738057375, -0.033847738057375, 
-0.0919496417045593, -0.0880158543586731, -0.0880158543586731
), month_8 = c(0.00105724367313087, 0.0109531516209245, -0.00258957524783909, 
-0.0119656454771757, -0.0273083839565516, -0.0315780155360699
), month_9 = c(0.040503092110157, 0.0272863991558552, 0.0342562571167946, 
0.0368664264678955, 0.0334650687873363, 0.0334650687873363), 
    month_10 = c(0.0210105869919062, 0.0340395793318748, 0.0246942117810249, 
    0.0683412477374077, 0.0773100107908249, 0.0828942507505417
    ), month_11 = c(0.0134705044329166, 0.0149277104064822, 0.0455087646842003, 
    0.0467537902295589, 0.0175258759409189, 0.00985155906528234
    ), month_12 = c(0.127066493034363, 0.0923486724495888, 0.200634613633156, 
    0.169035747647285, 0.19908843934536, 0.209459736943245)), row.names = c(NA, 
6L), class = "data.frame")))

资料清单2:

lst2 <- list(`5` = list(structure(list(sanchinarro = c(-1.00742964973274, 
0.832453587904369, 1.29242439731365, 1.03688505875294, 0.525806381631517, 
-0.291919501762755), date = structure(c(14610, 14611, 14612, 
14613, 14614, 14615), class = "Date"), holiday = c(1, 0, 0, 0, 
0, 1), temp = c(41.6, 41.9677419354839, 42.0967741935484, 45.1612903225806, 
47.3461538461538, 39.8333333333333), wind = c(19.72, 3.19354838709677, 
1.38709677419355, 3.2258064516129, 4.19230769230769, 8.08333333333333
), humidity = c(87.6, 87.741935483871, 91.2903225806452, 100, 
82.8461538461538, 65.5), barometer = c(29.8096, 30.1125806451613, 
30.0370967741936, 29.6761290322581, 29.5380769230769, 29.6625
), weekday = c(1, 0, 0, 1, 1, 1), weekend = c(0, 1, 1, 0, 0, 
0), workday_on_holiday = c(1, 0, 0, 0, 0, 1), weekend_on_holiday = c(0, 
0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(0, 
1, 0, 1, 1, 0), text_light_rain = c(0, 0, 0, 1, 0, 0), text_mostly_cloudy = c(0, 
0, 0, 0, 0, 0), text_passing_clouds = c(1, 1, 1, 1, 1, 1), text_rain = c(1, 
0, 1, 1, 0, 0), text_scattered_clouds = c(1, 1, 0, 1, 1, 1), 
    text_sunny = c(1, 1, 1, 1, 1, 0), month_1 = c(1, 1, 1, 1, 
    1, 1), month_2 = c(0, 0, 0, 0, 0, 0), month_3 = c(0, 0, 0, 
    0, 0, 0), month_4 = c(0, 0, 0, 0, 0, 0), month_5 = c(0, 0, 
    0, 0, 0, 0), month_6 = c(0, 0, 0, 0, 0, 0), month_7 = c(0, 
    0, 0, 0, 0, 0), month_8 = c(0, 0, 0, 0, 0, 0), month_9 = c(0, 
    0, 0, 0, 0, 0), month_10 = c(0, 0, 0, 0, 0, 0), month_11 = c(0, 
    0, 0, 0, 0, 0), month_12 = c(0, 0, 0, 0, 0, 0)), row.names = c(NA, 
6L), class = "data.frame"), structure(list(sanchinarro = c(0.832179838392013, 
1.29225734336885, 1.03665872949283, 0.525461501740789, -0.292454062662475, 
-0.394693508212883), date = structure(c(14611, 14612, 14613, 
14614, 14615, 14616), class = "Date"), holiday = c(0, 0, 0, 0, 
1, 0), temp = c(41.9677419354839, 42.0967741935484, 45.1612903225806, 
47.3461538461538, 39.8333333333333, 33.2903225806452), wind = c(3.19354838709677, 
1.38709677419355, 3.2258064516129, 4.19230769230769, 8.08333333333333, 
8.7741935483871), humidity = c(87.741935483871, 91.2903225806452, 
100, 82.8461538461538, 65.5, 95.6774193548387), barometer = c(30.1125806451613, 
30.0370967741936, 29.6761290322581, 29.5380769230769, 29.6625, 
29.4709677419355), weekday = c(0, 0, 1, 1, 1, 1), weekend = c(1, 
1, 0, 0, 0, 0), workday_on_holiday = c(0, 0, 0, 0, 1, 0), weekend_on_holiday = c(0, 
0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(1, 
0, 1, 1, 0, 1), text_light_rain = c(0, 0, 1, 0, 0, 1), text_mostly_cloudy = c(0, 
0, 0, 0, 0, 0), text_passing_clouds = c(1, 1, 1, 1, 1, 1), text_rain = c(0, 
1, 1, 0, 0, 1), text_scattered_clouds = c(1, 0, 1, 1, 1, 1), 
    text_sunny = c(1, 1, 1, 1, 0, 0), month_1 = c(1, 1, 1, 1, 
    1, 1), month_2 = c(0, 0, 0, 0, 0, 0), month_3 = c(0, 0, 0, 
    0, 0, 0), month_4 = c(0, 0, 0, 0, 0, 0), month_5 = c(0, 0, 
    0, 0, 0, 0), month_6 = c(0, 0, 0, 0, 0, 0), month_7 = c(0, 
    0, 0, 0, 0, 0), month_8 = c(0, 0, 0, 0, 0, 0), month_9 = c(0, 
    0, 0, 0, 0, 0), month_10 = c(0, 0, 0, 0, 0, 0), month_11 = c(0, 
    0, 0, 0, 0, 0), month_12 = c(0, 0, 0, 0, 0, 0)), row.names = c(NA, 
6L), class = "data.frame")), `6` = list(structure(list(el_pardo = c(-1.09741922422506, 
0.860173623751856, 1.0466110378449, 2.16523552240313, 1.13982974489142, 
-0.258450860806382), date = structure(c(14610, 14611, 14612, 
14613, 14614, 14615), class = "Date"), holiday = c(1, 0, 0, 0, 
0, 1), temp = c(41.6, 41.9677419354839, 42.0967741935484, 45.1612903225806, 
47.3461538461538, 39.8333333333333), wind = c(19.72, 3.19354838709677, 
1.38709677419355, 3.2258064516129, 4.19230769230769, 8.08333333333333
), humidity = c(87.6, 87.741935483871, 91.2903225806452, 100, 
82.8461538461538, 65.5), barometer = c(29.8096, 30.1125806451613, 
30.0370967741936, 29.6761290322581, 29.5380769230769, 29.6625
), weekday = c(1, 0, 0, 1, 1, 1), weekend = c(0, 1, 1, 0, 0, 
0), workday_on_holiday = c(1, 0, 0, 0, 0, 1), weekend_on_holiday = c(0, 
0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(0, 
1, 0, 1, 1, 0), text_light_rain = c(0, 0, 0, 1, 0, 0), text_mostly_cloudy = c(0, 
0, 0, 0, 0, 0), text_passing_clouds = c(1, 1, 1, 1, 1, 1), text_rain = c(1, 
0, 1, 1, 0, 0), text_scattered_clouds = c(1, 1, 0, 1, 1, 1), 
    text_sunny = c(1, 1, 1, 1, 1, 0), month_1 = c(1, 1, 1, 1, 
    1, 1), month_2 = c(0, 0, 0, 0, 0, 0), month_3 = c(0, 0, 0, 
    0, 0, 0), month_4 = c(0, 0, 0, 0, 0, 0), month_5 = c(0, 0, 
    0, 0, 0, 0), month_6 = c(0, 0, 0, 0, 0, 0), month_7 = c(0, 
    0, 0, 0, 0, 0), month_8 = c(0, 0, 0, 0, 0, 0), month_9 = c(0, 
    0, 0, 0, 0, 0), month_10 = c(0, 0, 0, 0, 0, 0), month_11 = c(0, 
    0, 0, 0, 0, 0), month_12 = c(0, 0, 0, 0, 0, 0)), row.names = c(NA, 
6L), class = "data.frame"), structure(list(el_pardo = c(0.859979282427802, 
1.04646685743811, 2.16539230749995, 1.13971064494326, -0.258946167634039, 
-0.631921317654653), date = structure(c(14611, 14612, 14613, 
14614, 14615, 14616), class = "Date"), holiday = c(0, 0, 0, 0, 
1, 0), temp = c(41.9677419354839, 42.0967741935484, 45.1612903225806, 
47.3461538461538, 39.8333333333333, 33.2903225806452), wind = c(3.19354838709677, 
1.38709677419355, 3.2258064516129, 4.19230769230769, 8.08333333333333, 
8.7741935483871), humidity = c(87.741935483871, 91.2903225806452, 
100, 82.8461538461538, 65.5, 95.6774193548387), barometer = c(30.1125806451613, 
30.0370967741936, 29.6761290322581, 29.5380769230769, 29.6625, 
29.4709677419355), weekday = c(0, 0, 1, 1, 1, 1), weekend = c(1, 
1, 0, 0, 0, 0), workday_on_holiday = c(0, 0, 0, 0, 1, 0), weekend_on_holiday = c(0, 
0, 0, 0, 0, 0), protocol_active = c(0, 0, 0, 0, 0, 0), text_fog = c(1, 
0, 1, 1, 0, 1), text_light_rain = c(0, 0, 1, 0, 0, 1), text_mostly_cloudy = c(0, 
0, 0, 0, 0, 0), text_passing_clouds = c(1, 1, 1, 1, 1, 1), text_rain = c(0, 
1, 1, 0, 0, 1), text_scattered_clouds = c(1, 0, 1, 1, 1, 1), 
    text_sunny = c(1, 1, 1, 1, 0, 0), month_1 = c(1, 1, 1, 1, 
    1, 1), month_2 = c(0, 0, 0, 0, 0, 0), month_3 = c(0, 0, 0, 
    0, 0, 0), month_4 = c(0, 0, 0, 0, 0, 0), month_5 = c(0, 0, 
    0, 0, 0, 0), month_6 = c(0, 0, 0, 0, 0, 0), month_7 = c(0, 
    0, 0, 0, 0, 0), month_8 = c(0, 0, 0, 0, 0, 0), month_9 = c(0, 
    0, 0, 0, 0, 0), month_10 = c(0, 0, 0, 0, 0, 0), month_11 = c(0, 
    0, 0, 0, 0, 0), month_12 = c(0, 0, 0, 0, 0, 0)), row.names = c(NA, 
6L), class = "data.frame")))

标签: r

解决方案


由于这些是两个lists 并且想从第二个数据中绑定“日期”列并将其与 的相应元素绑定lists,我们可以使用map2而不是map

library(purrr)
out <- map2_dfr(lst1, lst2, ~ map2_dfr(.x, map(.y, "date"),
        ~ cbind(.x, date = .y), .id = 'IDGroup2'), .id = 'IDGroup')
head(out)
#  IDGroup   IDGroup2    holiday         temp        wind   humidity    barometer    weekday weekend workday_on_holiday weekend_on_holiday
#1       5 2016-01-01 -0.2875051 -0.004131595 -0.68942320 0.08788958 -0.044270176 0.08152994       0       -0.004491160                  0
#2       5 2016-01-01 -0.2613214  0.075470507  0.15884757 0.11554980 -0.027390966 0.11183146       0       -0.004928516                  0
#3       5 2016-01-01 -0.2788497  0.148605376  0.84752327 0.08082478 -0.110819362 0.07685963       0       -0.009905681                  0
#4       5 2016-01-01 -0.2852835 -0.011284750  0.11122661 0.13438693 -0.013517623 0.09257593       0       -0.005359963                  0
#5       5 2016-01-01 -0.2827380  0.012600235 -0.08916214 0.16819011  0.017435972 0.07898130       0       -0.005911979                  0
#6       5 2016-01-01 -0.2799886  0.055347286 -0.29320240 0.07062373 -0.009474599 0.08682005       0       -0.004491160                  0
#  protocol_active   text_fog text_light_rain text_mostly_cloudy text_passing_clouds     text_rain text_scattered_clouds   text_sunny    month_1
#1               0 0.05453610      0.02055504       -0.003508107         0.011477915  0.0248998813           -0.08106078 0.0086088600 0.07640738
#2               0 0.07014788      0.03472626       -0.010609524         0.014214168 -0.0004061495           -0.07777867 0.0031850194 0.16343993
#3               0 0.02396879      0.03373001       -0.008926486         0.008658116 -0.0329548903           -0.17243122 0.0063267332 0.08468129
#4               0 0.06937934      0.02769369        0.007768817         0.023657059 -0.0005894799           -0.08510636 0.0009107648 0.15761615
#5               0 0.07031541      0.02747060       -0.024575127         0.014786102  0.0011341455           -0.07967515 0.0057251817 0.07625937
#6               0 0.04563824      0.02055504       -0.014174540         0.014693571 -0.0004061495           -0.09679305 0.0106474124 0.08535635
#      month_2       month_3     month_4     month_5      month_6     month_7     month_8    month_9   month_10   month_11   month_12       date
#1 0.045578238  0.0033622182 -0.06274214 -0.07467288 -0.032955777 -0.01001179 -0.03556978 0.01872355 0.07136117 0.05808590 0.15059333 2010-01-01
#2 0.018249372  0.0044576218 -0.17375310 -0.14704236 -0.007879189 -0.01295435 -0.04510764 0.01888210 0.07714521 0.08734045 0.25044793 2010-01-02
#3 0.002464291 -0.0292761438 -0.08312281 -0.08700808 -0.007707109 -0.01470387 -0.04435510 0.01596025 0.05754736 0.05717132 0.08667592 2010-01-03
#4 0.039944258 -0.0004514736 -0.15914200 -0.15421098 -0.008650888 -0.01224635 -0.04510764 0.01888210 0.07671589 0.08638439 0.17999160 2010-01-04
#5 0.047762766  0.0162581336 -0.14487271 -0.08386189 -0.008392147 -0.01224635 -0.04510764 0.01905395 0.07042630 0.11087914 0.11585888 2010-01-05
#6 0.022514986  0.0057770289 -0.13264991 -0.10598666 -0.037495021 -0.01280877 -0.03657964 0.01905395 0.07222101 0.08583542 0.17929509 2010-01-06

推荐阅读