修剪一些日期的“尾巴”

时间:2018-11-05 22:21:28

标签: r

我有两个分别称为main_dfusd_eur的数据帧。 main_df有每周数据,而usd_eur有每日数据。

第二,我尝试使用usd_eur软件包将tidyquant数据转换为每周数据

library(tidyquant)

    x <- usd_eur %>%
      tq_transmute(select     = DEXUSEU,
                   mutate_fun = apply.weekly,
                   FUN        = mean)

但是,首先,我在usd_eur中的数据两边各有大约一个月的时间,拥有“太多”的main_df数据。

min(main_df$WEEK)
min(usd_eur$DATE)

max(main_df$WEEK)
max(usd_eur$DATE)

因此,我正在尝试修剪尾端,以便两个数据帧都在同一天开始,然后将usd_eur中的每日数据转换为每周数据。但是,我在思考如何修剪数据的尾端时遇到了一些困难。

Main_df:

main_df <- structure(list(WEEK = structure(c(1333922400, 1326668400, 1330902000, 
1329692400, 1353884400, 1335736800, 1331506800, 1345413600, 1325458800, 
1338156000, 1327273200, 1346018400, 1346623200, 1326063600, 1355094000, 
1344808800, 1326668400, 1327878000, 1349647200, 1327878000, 1349647200, 
1333922400, 1354489200, 1327273200, 1339365600, 1340575200, 1336946400, 
1338760800, 1336946400, 1355698800, 1331506800, 1344808800, 1336946400, 
1341784800, 1325458800, 1355698800, 1333317600, 1330297200, 1342994400, 
1342994400, 1339970400, 1347832800, 1342389600, 1354489200, 1333317600, 
1333317600, 1329692400, 1355698800, 1339365600, 1332712800, 1338760800, 
1333317600, 1347228000, 1335736800, 1349647200, 1336341600, 1349647200, 
1337551200, 1333922400, 1348437600, 1342389600, 1349647200, 1346623200, 
1341180000, 1330297200, 1327273200, 1352070000, 1345413600, 1342994400, 
1347832800, 1338760800, 1350856800, 1350252000, 1344808800, 1355698800, 
1333922400, 1345413600, 1351465200, 1344204000, 1344808800, 1350252000, 
1339970400, 1324854000, 1327878000, 1335736800, 1350252000, 1353279600, 
1336946400, 1343599200, 1346623200, 1339365600, 1336341600, 1329087600, 
1338156000, 1339970400, 1341180000, 1353884400, 1336341600, 1327878000, 
1329692400, 1355094000, 1349647200, 1346623200, 1349042400, 1334527200, 
1349647200, 1343599200, 1347832800, 1330902000, 1330297200, 1336341600, 
1354489200, 1330902000, 1333922400, 1352674800, 1350252000, 1336946400, 
1355094000, 1344204000, 1346018400, 1344808800, 1328482800, 1330297200, 
1348437600, 1341180000, 1341180000, 1344808800, 1354489200, 1355698800, 
1330902000, 1344204000, 1338156000, 1350856800, 1337551200, 1324854000, 
1338156000, 1338156000, 1350252000, 1337551200, 1347228000, 1351465200, 
1335132000, 1341180000, 1347832800, 1335736800, 1336341600, 1349042400, 
1353279600, 1352070000, 1334527200, 1349647200, 1330297200, 1355094000, 
1327273200, 1338156000, 1347228000, 1326063600, 1342994400, 1329087600, 
1330297200, 1349647200, 1329692400, 1350856800, 1329692400, 1346623200, 
1335736800, 1341784800, 1344808800, 1341784800, 1344808800, 1341784800, 
1355094000, 1352070000, 1333922400, 1340575200, 1331506800, 1326063600, 
1333922400, 1341180000, 1345413600, 1353884400, 1344808800, 1348437600, 
1327878000, 1343599200, 1339365600, 1338156000, 1338760800, 1326063600, 
1346623200, 1352674800, 1332111600, 1353884400, 1355698800, 1325458800, 
1342994400, 1341784800, 1339970400, 1335132000, 1333922400, 1348437600, 
1350252000, 1347228000, 1339365600, 1347228000, 1353884400, 1346623200, 
1355698800, 1332111600, 1346018400, 1330902000, 1342994400, 1331506800, 
1328482800, 1331506800, 1349042400, 1324854000, 1324854000, 1350856800, 
1350252000, 1348437600, 1339365600, 1346623200, 1343599200, 1345413600, 
1337551200, 1355698800, 1332111600, 1335736800, 1349647200, 1348437600, 
1343599200, 1336341600, 1345413600, 1339365600, 1332712800, 1345413600, 
1348437600, 1347832800, 1333922400, 1330902000, 1324854000, 1354489200, 
1355698800, 1326063600, 1343599200, 1350252000, 1353884400, 1355698800, 
1327273200, 1342994400, 1341180000, 1355094000, 1353884400, 1347832800, 
1327273200, 1333317600, 1348437600, 1342994400, 1326668400, 1355094000, 
1349042400, 1332111600, 1350252000, 1344808800, 1344204000, 1353884400, 
1341180000, 1349647200, 1344204000, 1352674800, 1340575200, 1327273200, 
1350252000, 1349042400, 1349647200, 1347228000, 1353279600, 1343599200, 
1342389600, 1353884400, 1339970400, 1334527200, 1343599200, 1350856800, 
1346018400, 1329087600, 1336946400, 1334527200, 1350856800, 1341180000, 
1326668400, 1337551200, 1346018400, 1346623200, 1343599200, 1324854000, 
1339970400, 1346623200, 1340575200, 1334527200, 1324854000, 1338760800, 
1346018400, 1327273200, 1324854000, 1335736800, 1351465200, 1347228000, 
1341180000, 1335736800, 1338156000, 1333922400, 1338156000, 1334527200, 
1329087600, 1356303600, 1346018400, 1330902000, 1333922400, 1339365600, 
1338156000, 1353884400, 1344204000, 1336341600, 1337551200, 1354489200, 
1334527200, 1332712800, 1349647200, 1344204000, 1353279600, 1336341600, 
1347832800, 1353884400, 1353884400, 1341784800, 1353884400, 1347832800, 
1342389600, 1332111600, 1342994400, 1347228000, 1341784800, 1326063600, 
1330297200, 1354489200, 1332111600, 1350252000, 1326063600, 1353884400, 
1324854000, 1336341600, 1340575200, 1331506800, 1350252000, 1348437600, 
1326668400, 1350856800, 1332111600, 1347832800, 1349042400, 1352070000, 
1335736800, 1343599200, 1324854000, 1355698800, 1341784800, 1342994400, 
1343599200, 1330297200, 1335736800, 1338156000, 1339365600, 1341784800, 
1325458800, 1329692400, 1339970400, 1351465200, 1344808800, 1324854000, 
1356303600, 1338156000, 1353279600, 1342389600, 1355698800, 1327878000, 
1326063600, 1347228000, 1341784800, 1335132000, 1335132000, 1340575200, 
1329087600, 1347832800, 1350856800, 1338156000, 1326063600, 1347228000, 
1352674800, 1333922400, 1336946400, 1340575200, 1330902000, 1325458800, 
1342994400, 1336341600, 1346623200, 1339365600, 1355094000, 1353279600, 
1355698800, 1355698800, 1336341600, 1324854000, 1333317600, 1347832800, 
1345413600, 1339970400, 1342994400, 1353279600, 1339365600, 1342389600, 
1350856800, 1339365600, 1332712800, 1352674800, 1341784800, 1339365600, 
1342994400, 1345413600, 1348437600, 1340575200, 1352674800, 1346018400, 
1324854000, 1335736800, 1352674800, 1349042400, 1324854000, 1332111600, 
1346018400, 1335132000, 1338156000, 1327273200, 1335736800, 1345413600, 
1346623200, 1328482800, 1353279600, 1355698800, 1335132000, 1330902000, 
1355094000, 1342994400, 1350252000, 1352070000, 1330297200, 1340575200, 
1334527200, 1347228000, 1344808800, 1347832800, 1351465200, 1342994400, 
1327273200, 1333317600, 1341784800, 1346018400, 1353884400, 1341784800, 
1353279600, 1335132000, 1350252000, 1337551200, 1326063600, 1341784800, 
1349647200, 1351465200, 1329692400, 1331506800, 1327878000, 1352070000, 
1332111600, 1338156000, 1331506800, 1350252000, 1346623200, 1335132000, 
1325458800, 1349647200, 1328482800, 1324854000, 1355094000, 1327273200, 
1343599200, 1330297200, 1350252000, 1343599200, 1326668400), class = c("POSIXct", 
"POSIXt"), tzone = ""), DOLLARS = c(95.52, 20.98, 24.38, 242.77, 
17.99, 14.94, 11.78, 29.95, 8.99, 56.52, 20.99, 84.95, 388.48, 
95.22, 24.38, 94.95, 9.99, 19.98, 11.49, 17, 17.79, 2.59, 12.99, 
13.99, 51.96, 241.27, 6.76, 863.46, 38.97, 49.95, 7.49, 131.88, 
32.97, 189.88, 16.76, 19.47, 41.93, 17.97, 34.93, 199.9, 307.86, 
49.95, 54.95, 8.99, 7.67, 59.95, 218.79, 6.99, 15.49, 87.96, 
37.45, 92.9, 70.74, 25.47, 83.88, 14.99, 56.97, 17.98, 38.45, 
12.99, 59.31, 612.64, 6.9, 48.93, 7.99, 33.98, 9.96, 59.94, 27.96, 
7.49, 17.97, 38.97, 19.47, 98.91, 1.67, 27, 89.95, 8.99, 2.59, 
35.97, 25.33, 15.99, 27.46, 27.17, 16.99, 7.56, 16.98, 94.43, 
33.98, 14.99, 10.9, 13.93, 10.48, 208.85, 25.96, 23.96, 23.97, 
4.38, 21.98, 14.95, 34.47, 47.97, 27.54, 54.95, 12.99, 21.56, 
59.96, 47.94, 11.78, 108.43, 9.98, 19.99, 35.97, 19.98, 50.36, 
87.76, 18.98, 39.95, 22.77, 9.49, 152.91, 26.98, 122.13, 8.99, 
152.91, 71.96, 94.24, 12.29, 29.97, 23.98, 284.68, 16.49, 6.99, 
2.98, 22.98, 436.81, 239.28, 37.45, 25.98, 50.97, 27.98, 11.96, 
12.75, 17.97, 19.98, 6.59, 12.49, 13.99, 71.46, 7.58, 6.57, 8.79, 
6.39, 32.97, 21.97, 31.88, 11.38, 26.45, 37.29, 8.49, 5.69, 13.49, 
13.18, 27.87, 5.79, 5.84, 47.49, 29.98, 47.96, 34.62, 32.97, 
29.94, 49.95, 127.92, 8.49, 9.99, 13.98, 6.79, 48.86, 21.98, 
22.38, 43.47, 113.82, 27.98, 276.76, 25.47, 203.83, 29.9, 18.49, 
12.9, 13.99, 23.96, 9.99, 6.49, 55.92, 33.98, 7.49, 23.97, 9.59, 
83.93, 34.95, 60.72, 4.19, 35.96, 17.98, 107.94, 12.98, 8.49, 
24.98, 2.79, 50.94, 32.97, 27.18, 23.18, 59.95, 4.18, 15.99, 
27.45, 14.49, 9.96, 8.99, 11.99, 33.95, 223.86, 7.99, 17.8, 23.97, 
27.98, 41.94, 57.92, 24.51, 21.42, 32.98, 27.96, 12.28, 13.98, 
43.96, 113.94, 47.96, 35.56, 6.39, 23.38, 49.44, 299.85, 3.98, 
6.87, 37.94, 11.99, 27.09, 29.97, 5.01, 6.49, 12.98, 11.79, 83.93, 
175.84, 27.9, 17.98, 70.14, 7.99, 20.97, 43.98, 154.66, 45.43, 
11.79, 103.89, 125.94, 22.47, 19.94, 92.94, 24.87, 188.93, 36.96, 
16.49, 179.8, 1.49, 7.99, 44.97, 25.94, 79.96, 90.79, 39.96, 
84.95, 49.57, 41.96, 92.64, 9.98, 21.89, 13.98, 3.39, 14.07, 
12.49, 39.87, 15.98, 37.95, 27.96, 53.97, 241.78, 15.9, 37.53, 
90.91, 5.29, 76.41, 62.93, 6.99, 52.43, 7.99, 55.12, 19.47, 111.93, 
41.61, 6.99, 23.56, 115.92, 13.99, 13.98, 146.93, 5.58, 71.91, 
34.47, 1.49, 7.49, 14.97, 50.97, 9.98, 10.99, 2.99, 58.95, 14.49, 
73.43, 17.97, 19.96, 19.99, 58.05, 24.43, 8.99, 27.96, 159.7, 
98.94, 11.49, 7.99, 6.49, 65.87, 134.91, 31.47, 12.69, 7.49, 
83.23, 6.99, 73.95, 19.99, 3.49, 31.96, 12.99, 8.69, 15.12, 35.97, 
12.38, 90.93, 46.08, 7.49, 116.41, 14.99, 7.99, 600.14, 28.98, 
127.89, 223.68, 23.98, 71.92, 1.39, 47.97, 35.94, 13.12, 76.93, 
350.49, 34.93, 69.9, 35.97, 12.58, 6.99, 4.99, 41.94, 179.85, 
14.07, 14.98, 19.98, 34.95, 30.95, 23.97, 55.16, 6.41, 191.58, 
17.98, 9.49, 19.98, 6.98, 59.77, 27.98, 41.97, 90.93, 83.88, 
155.88, 5.18, 6.49, 19.47, 51.92, 10.99, 47.45, 71.95, 7.99, 
119.92, 75.96, 13.99, 69.54, 17.99, 123.6, 125.91, 23.91, 35.97, 
117.8, 15.98, 59.95, 41.43, 20.07, 95.84, 36.87, 31.96, 7.99, 
51.92, 17.78, 34.95, 29.77, 19.9, 15.98, 16.99, 16.99, 55.92, 
9.99, 25.96, 47.53, 11.99, 19.47, 41.96, 11.49, 71.88, 41.93, 
32.73, 11.88, 12.99, 119.92, 45.43, 33.83, 35.98, 4.59, 22.45, 
17.99, 19.74, 63.48, 23.98, 12.99, 19.35, 47.96, 269.7, 19.99, 
6.99, 39.97, 16.03, 12.78, 21.98, 61.95, 1371.02, 8.99, 27.98, 
22.47, 28.38, 21.16, 378.1, 12.99, 21.98, 10.76, 1237.28, 33.98, 
87.45, 33.74, 29.37, 42.98, 63.92, 359.7, 21.98, 74.94, 6.99, 
95.94, 42.45, 26.97, 41.96, 42.96, 12.18, 208.81, 39.95)), row.names = c(1067085L, 
215963L, 695890L, 542508L, 3493756L, 1298696L, 774268L, 2478662L, 
116514L, 1553136L, 332795L, 2563070L, 2577393L, 174830L, 3635833L, 
2421542L, 266133L, 361174L, 3004166L, 353089L, 2996911L, 1075234L, 
3509258L, 318074L, 1731067L, 1843791L, 1439070L, 1665855L, 1445756L, 
3669998L, 758864L, 2383243L, 1399477L, 2002339L, 102756L, 3671411L, 
983765L, 624399L, 2144771L, 2166916L, 1784261L, 2772164L, 2106279L, 
3565801L, 1001965L, 986312L, 557264L, 3659289L, 1740736L, 894697L, 
1614805L, 969601L, 2662675L, 1264970L, 2996498L, 1368358L, 2944534L, 
1490066L, 1045369L, 2860282L, 2066261L, 2987232L, 2630020L, 1932165L, 
661937L, 296168L, 3230212L, 2477680L, 2150242L, 2783412L, 1646335L, 
3089505L, 3075076L, 2397830L, 3710084L, 1028996L, 2474105L, 3215408L, 
2278943L, 2411135L, 3067217L, 1773674L, 38887L, 401184L, 1297100L, 
3042275L, 3410896L, 1424973L, 2222265L, 2648041L, 1695595L, 1377225L, 
521671L, 1544541L, 1767264L, 1963030L, 3444565L, 1341729L, 401481L, 
548546L, 3601517L, 2987866L, 2618970L, 2873147L, 1111789L, 2942108L, 
2256488L, 2726525L, 723893L, 628294L, 1367413L, 3511639L, 685682L, 
1094595L, 3322174L, 3053755L, 1442106L, 3583297L, 2308210L, 2529293L, 
2373771L, 444853L, 618100L, 2856566L, 1961317L, 1909695L, 2419685L, 
3561956L, 3655596L, 681822L, 2318916L, 1551799L, 3118438L, 1517592L, 
17440L, 1539626L, 1572084L, 3014164L, 1468338L, 2709841L, 3153821L, 
1229910L, 1971637L, 2730029L, 1301880L, 1370811L, 2895735L, 3412539L, 
3237167L, 1115923L, 2973931L, 643196L, 3588099L, 304837L, 1604918L, 
2712866L, 158333L, 2135002L, 474408L, 632409L, 2948616L, 571239L, 
3114992L, 587125L, 2624905L, 1287525L, 2014178L, 2424031L, 2044073L, 
2400491L, 2001621L, 3617547L, 3264220L, 1046709L, 1854960L, 811932L, 
181718L, 1044732L, 1945162L, 2486974L, 3469672L, 2403413L, 2797402L, 
394128L, 2271447L, 1721010L, 1572527L, 1639366L, 182673L, 2612748L, 
3292131L, 818933L, 3499833L, 3714599L, 75629L, 2198226L, 1994934L, 
1812600L, 1185085L, 1082880L, 2838867L, 3055149L, 2669804L, 1752208L, 
2705260L, 3480374L, 2647539L, 3714531L, 871391L, 2507399L, 723894L, 
2200958L, 780059L, 405180L, 782068L, 2905928L, 68187L, 42981L, 
3104656L, 3062006L, 2835449L, 1719490L, 2585721L, 2227671L, 2460948L, 
1494520L, 3672026L, 869678L, 1286661L, 2994102L, 2807955L, 2206519L, 
1368665L, 2426230L, 1726070L, 908377L, 2498474L, 2823230L, 2766676L, 
1028857L, 700138L, 9879L, 3536310L, 3654290L, 139304L, 2255060L, 
3032042L, 3483899L, 3652261L, 329688L, 2164534L, 1917489L, 3614261L, 
3451976L, 2733499L, 279044L, 1011042L, 2830128L, 2159375L, 248078L, 
3599641L, 2907169L, 856910L, 3015843L, 2375987L, 2334668L, 3440617L, 
1957037L, 2938953L, 2334358L, 3347294L, 1858984L, 289275L, 3021866L, 
2875137L, 2952229L, 2648784L, 3402699L, 2267390L, 2122828L, 3494803L, 
1811267L, 1154394L, 2220065L, 3143521L, 2540283L, 515283L, 1394405L, 
1100908L, 3100919L, 1931713L, 224852L, 1515470L, 2550823L, 2585843L, 
2205106L, 49921L, 1756712L, 2615322L, 1872578L, 1147685L, 42797L, 
1608974L, 2533577L, 303558L, 63584L, 1246552L, 3206334L, 2664307L, 
1909454L, 1262989L, 1582988L, 1073060L, 1589263L, 1144996L, 506611L, 
3722494L, 2562617L, 684182L, 1077921L, 1751763L, 1561735L, 3447080L, 
2309060L, 1325598L, 1527619L, 3564899L, 1160155L, 928592L, 2987410L, 
2283147L, 3374910L, 1358508L, 2777970L, 3459813L, 3502999L, 1982405L, 
3438085L, 2722385L, 2091611L, 843831L, 2160946L, 2656606L, 2041818L, 
173138L, 638341L, 3566766L, 826145L, 3062436L, 153020L, 3465111L, 
9589L, 1339391L, 1902773L, 794107L, 3043314L, 2821033L, 233030L, 
3096095L, 868440L, 2791044L, 2917033L, 3226037L, 1248575L, 2235911L, 
56621L, 3667101L, 2035958L, 2144544L, 2270138L, 641683L, 1303011L, 
1567192L, 1722663L, 2046502L, 109181L, 586127L, 1770274L, 3153948L, 
2369445L, 40666L, 3743004L, 1561080L, 3381855L, 2089364L, 3643832L, 
363084L, 178403L, 2707344L, 2008394L, 1184023L, 1198491L, 1867308L, 
480265L, 2724107L, 3111252L, 1588046L, 151876L, 2660866L, 3308046L, 
1034216L, 1387420L, 1863976L, 736245L, 107660L, 2151952L, 1365425L, 
2629458L, 1683762L, 3575242L, 3403068L, 3704931L, 3650732L, 1339028L, 
38635L, 975257L, 2725681L, 2451252L, 1752828L, 2142408L, 3391588L, 
1700218L, 2087478L, 3097591L, 1736364L, 913222L, 3330310L, 2033639L, 
1741946L, 2141472L, 2476358L, 2823224L, 1870985L, 3356384L, 2530017L, 
49236L, 1299786L, 3325431L, 2916832L, 62154L, 824665L, 2569495L, 
1196336L, 1540341L, 266435L, 1297144L, 2487104L, 2638212L, 445823L, 
3421156L, 3645716L, 1214442L, 719959L, 3627922L, 2178321L, 3014396L, 
3251809L, 649492L, 1886266L, 1128012L, 2720899L, 2388080L, 2723254L, 
3200431L, 2197946L, 323964L, 1009149L, 1988763L, 2558475L, 3437334L, 
2028259L, 3412562L, 1192991L, 3013891L, 1510521L, 153101L, 2016120L, 
2985822L, 3189660L, 605723L, 776308L, 382304L, 3283285L, 842636L, 
1555501L, 807298L, 3072765L, 2579254L, 1171685L, 119273L, 2962404L, 
437876L, 5714L, 3630770L, 318358L, 2246554L, 639439L, 3012437L, 
2270094L, 261077L), class = "data.frame")

货币df

usd_eur <- structure(list(DATE = structure(c(1322521200, 1322607600, 1322694000, 
1322780400, 1323039600, 1323126000, 1323212400, 1323298800, 1323385200, 
1323644400, 1323730800, 1323817200, 1323903600, 1323990000, 1324249200, 
1324335600, 1324422000, 1324508400, 1324594800, 1324854000, 1324940400, 
1325026800, 1325113200, 1325199600, 1325458800, 1325545200, 1325631600, 
1325718000, 1325804400, 1326063600, 1326150000, 1326236400, 1326322800, 
1326409200, 1326668400, 1326754800, 1326841200, 1326927600, 1327014000, 
1327273200, 1327359600, 1327446000, 1327532400, 1327618800, 1327878000, 
1327964400, 1328050800, 1328137200, 1328223600, 1328482800, 1328569200, 
1328655600, 1328742000, 1328828400, 1329087600, 1329174000, 1329260400, 
1329346800, 1329433200, 1329692400, 1329778800, 1329865200, 1329951600, 
1330038000, 1330297200, 1330383600, 1330470000, 1330556400, 1330642800, 
1330902000, 1330988400, 1331074800, 1331161200, 1331247600, 1331506800, 
1331593200, 1331679600, 1331766000, 1331852400, 1332111600, 1332198000, 
1332284400, 1332370800, 1332457200, 1332712800, 1332799200, 1332885600, 
1332972000, 1333058400, 1333317600, 1333404000, 1333490400, 1333576800, 
1333663200, 1333922400, 1334008800, 1334095200, 1334181600, 1334268000, 
1334527200, 1334613600, 1334700000, 1334786400, 1334872800, 1335132000, 
1335218400, 1335304800, 1335391200, 1335477600, 1335736800, 1335823200, 
1335909600, 1335996000, 1336082400, 1336341600, 1336428000, 1336514400, 
1336600800, 1336687200, 1336946400, 1337032800, 1337119200, 1337205600, 
1337292000, 1337551200, 1337637600, 1337724000, 1337810400, 1337896800, 
1338156000, 1338242400, 1338328800, 1338415200, 1338501600, 1338760800, 
1338847200, 1338933600, 1339020000, 1339106400, 1339365600, 1339452000, 
1339538400, 1339624800, 1339711200, 1339970400, 1340056800, 1340143200, 
1340229600, 1340316000, 1340575200, 1340661600, 1340748000, 1340834400, 
1340920800, 1341180000, 1341266400, 1341352800, 1341439200, 1341525600, 
1341784800, 1341871200, 1341957600, 1342044000, 1342130400, 1342389600, 
1342476000, 1342562400, 1342648800, 1342735200, 1342994400, 1343080800, 
1343167200, 1343253600, 1343340000, 1343599200, 1343685600, 1343772000, 
1343858400, 1343944800, 1344204000, 1344290400, 1344376800, 1344463200, 
1344549600, 1344808800, 1344895200, 1344981600, 1345068000, 1345154400, 
1345413600, 1345500000, 1345586400, 1345672800, 1345759200, 1346018400, 
1346104800, 1346191200, 1346277600, 1346364000, 1346623200, 1346709600, 
1346796000, 1346882400, 1346968800, 1347228000, 1347314400, 1347400800, 
1347487200, 1347573600, 1347832800, 1347919200, 1348005600, 1348092000, 
1348178400, 1348437600, 1348524000, 1348610400, 1348696800, 1348783200, 
1349042400, 1349128800, 1349215200, 1349301600, 1349388000, 1349647200, 
1349733600, 1349820000, 1349906400, 1349992800, 1350252000, 1350338400, 
1350424800, 1350511200, 1350597600, 1350856800, 1350943200, 1351029600, 
1351116000, 1351202400, 1351465200, 1351551600, 1351638000, 1351724400, 
1351810800, 1352070000, 1352156400, 1352242800, 1352329200, 1352415600, 
1352674800, 1352761200, 1352847600, 1352934000, 1353020400, 1353279600, 
1353366000, 1353452400, 1353538800, 1353625200, 1353884400, 1353970800, 
1354057200, 1354143600, 1354230000, 1354489200, 1354575600, 1354662000, 
1354748400, 1354834800, 1355094000, 1355180400, 1355266800, 1355353200, 
1355439600, 1355698800, 1355785200, 1355871600, 1355958000, 1356044400, 
1356303600, 1356390000, 1356476400, 1356562800, 1356649200, 1356908400, 
1356994800, 1357081200, 1357167600, 1357254000, 1357513200, 1357599600, 
1357686000, 1357772400, 1357858800, 1358118000, 1358204400, 1358290800, 
1358377200, 1358463600, 1358722800, 1358809200, 1358895600, 1358982000, 
1359068400, 1359327600, 1359414000, 1359500400), class = c("POSIXct", 
"POSIXt"), tzone = ""), DEXUSEU = c(1.3343, 1.3453, 1.3487, 1.3386, 
1.3463, 1.3397, 1.3386, 1.3324, 1.3368, 1.3188, 1.3094, 1.2972, 
1.3013, 1.3025, 1.3017, 1.3076, 1.304, 1.3045, 1.304, NA, 1.3074, 
1.2926, 1.2952, 1.2973, NA, 1.3061, 1.293, 1.2783, 1.2723, 1.2745, 
1.2782, 1.2686, 1.2818, 1.2682, NA, 1.274, 1.2825, 1.2937, 1.2948, 
1.3035, 1.3004, 1.2978, 1.3152, 1.3192, 1.3123, 1.3053, 1.3179, 
1.3167, 1.3106, 1.313, 1.3244, 1.3253, 1.3297, 1.3187, 1.3211, 
1.3149, 1.3087, 1.311, 1.3149, NA, 1.3255, 1.3251, 1.3308, 1.3463, 
1.341, 1.3452, 1.3359, 1.332, 1.3202, 1.3226, 1.3114, 1.3149, 
1.3256, 1.3108, 1.3141, 1.3109, 1.3025, 1.307, 1.3171, 1.3242, 
1.3222, 1.319, 1.3194, 1.3263, 1.3328, 1.3336, 1.33, 1.3265, 
1.3334, 1.3325, 1.3337, 1.3126, 1.3064, 1.3089, 1.3087, 1.3068, 
1.3104, 1.3171, 1.3082, 1.3067, 1.3123, 1.3122, 1.3132, 1.3212, 
1.3129, 1.3207, 1.321, 1.3232, 1.3248, 1.3229, 1.3226, 1.3154, 
1.3147, 1.3091, 1.3052, 1.3015, 1.2954, 1.2959, 1.2937, 1.2847, 
1.2769, 1.273, 1.2709, 1.2721, 1.2769, 1.2735, 1.2569, 1.2583, 
1.2518, NA, 1.2488, 1.2405, 1.2364, 1.242, 1.2495, 1.2437, 1.2535, 
1.2568, 1.2482, 1.2504, 1.2477, 1.2596, 1.2608, 1.2633, 1.2578, 
1.2692, 1.2703, 1.2586, 1.2545, 1.248, 1.2471, 1.2457, 1.2433, 
1.2668, 1.2584, 1.262, NA, 1.2384, 1.2283, 1.2299, 1.2255, 1.2244, 
1.2199, 1.2232, 1.2267, 1.2234, 1.2261, 1.2257, 1.2176, 1.2126, 
1.2062, 1.2132, 1.228, 1.237, 1.225, 1.2315, 1.2299, 1.2149, 
1.239, 1.2422, 1.2422, 1.2364, 1.2278, 1.2298, 1.2339, 1.2329, 
1.2288, 1.2356, 1.2315, 1.2343, 1.2472, 1.2472, 1.2583, 1.2533, 
1.2514, 1.2564, 1.2538, 1.2497, 1.2578, NA, 1.2566, 1.2603, 1.2626, 
1.2796, 1.2795, 1.2858, 1.2894, 1.2912, 1.3142, 1.3125, 1.3051, 
1.3065, 1.2948, 1.299, 1.2909, 1.2945, 1.2852, 1.2874, 1.2856, 
1.29, 1.2951, 1.2909, 1.3001, 1.3059, NA, 1.2876, 1.2888, 1.2928, 
1.2946, 1.295, 1.3036, 1.3133, 1.3106, 1.3022, 1.3063, 1.2971, 
1.2946, 1.2958, 1.2938, 1.2906, 1.2979, 1.2958, 1.2937, 1.2848, 
1.279, 1.2818, 1.2759, 1.274, 1.2715, NA, 1.2716, 1.274, 1.2783, 
1.2715, 1.2806, 1.2814, 1.2816, NA, 1.2959, 1.2966, 1.294, 1.2923, 
1.2953, 1.301, 1.3066, 1.3081, 1.3077, 1.2968, 1.2942, 1.293, 
1.2992, 1.3038, 1.3077, 1.3134, 1.3169, 1.3224, 1.326, 1.3224, 
1.3166, 1.3179, NA, 1.3228, 1.3228, 1.322, 1.3186, NA, 1.3195, 
1.311, 1.3047, 1.3099, 1.3068, 1.3078, 1.322, 1.3353, 1.3369, 
1.3342, 1.3305, 1.3356, 1.3303, NA, 1.3304, 1.3308, 1.3378, 1.3456, 
1.3459, 1.3484, 1.3564)), row.names = c(NA, -307L), class = "data.frame")

1 个答案:

答案 0 :(得分:0)

这是一种方法-

result <- usd_eur[usd_eur$DATE >= min(main_df$WEEK) & usd_eur$DATE <= max(main_df$WEEK), ]

> min(main_df$WEEK)
[1] "2011-12-25 18:00:00 EST"

> min(result$DATE)
[1] "2011-12-25 18:00:00 EST"
> 
> max(main_df$WEEK)
[1] "2012-12-23 18:00:00 EST"

> max(result$DATE)
[1] "2012-12-23 18:00:00 EST"