Check date of a year not present in dataset - r

doing this in R,
I have a set of 361 observations, "Dataset", 2 columns: Date and some numeric. All the dates present are between 2015-01-01 and 2015-12-31. Obviously there are 4 days that don't exist in this set, I would like to know which ones.
I tried to do:
MA <- rep(NA, 365)
for(i in 2:365){
MA[1] <- as.Date("2015-01-01")
MA[i] <- MA[i-1] + days(1)
}
MA[!(%in% Dataset$Date)]
But doesn't work... The vector MA consists of 365 times the number 16436
Anything solution for that?
EDIT:
This is set I called Dataset above:
dput(AW1)
structure(list(Date = structure(c(1420070400, 1420243200, 1420329600,
1420416000, 1420502400, 1420588800, 1420675200, 1420761600, 1420848000,
1420934400, 1421020800, 1421107200, 1421193600, 1421280000, 1421366400,
1421452800, 1421539200, 1421625600, 1421712000, 1421798400, 1421884800,
1421971200, 1422057600, 1422144000, 1422230400, 1422316800, 1422403200,
1422489600, 1422576000, 1422662400, 1422748800, 1422835200, 1422921600,
1423008000, 1423094400, 1423180800, 1423267200, 1423353600, 1423440000,
1423526400, 1423612800, 1423699200, 1423785600, 1423872000, 1423958400,
1424044800, 1424131200, 1424217600, 1424304000, 1424390400, 1424476800,
1424563200, 1424649600, 1424736000, 1424822400, 1424908800, 1424995200,
1425081600, 1425168000, 1425254400, 1425340800, 1425427200, 1425513600,
1425600000, 1425686400, 1425772800, 1425859200, 1425945600, 1426032000,
1426118400, 1426204800, 1426291200, 1426377600, 1426464000, 1426550400,
1426636800, 1426723200, 1426809600, 1426896000, 1426982400, 1427068800,
1427155200, 1427241600, 1427328000, 1427414400, 1427500800, 1427587200,
1427673600, 1427760000, 1427846400, 1427932800, 1428019200, 1428105600,
1428192000, 1428278400, 1428364800, 1428451200, 1428537600, 1428624000,
1428710400, 1428796800, 1428883200, 1428969600, 1429056000, 1429142400,
1429228800, 1429315200, 1429401600, 1429488000, 1429574400, 1429660800,
1429747200, 1429833600, 1429920000, 1430006400, 1430092800, 1430179200,
1430265600, 1430352000, 1430438400, 1430524800, 1430611200, 1430697600,
1430784000, 1430870400, 1430956800, 1431043200, 1431129600, 1431216000,
1431302400, 1431388800, 1431475200, 1431561600, 1431734400, 1431820800,
1431907200, 1431993600, 1432080000, 1432166400, 1432252800, 1432339200,
1432425600, 1432512000, 1432598400, 1432684800, 1432771200, 1432857600,
1432944000, 1433030400, 1433116800, 1433203200, 1433289600, 1433376000,
1433462400, 1433548800, 1433635200, 1433721600, 1433808000, 1433894400,
1433980800, 1434067200, 1434153600, 1434240000, 1434326400, 1434412800,
1434499200, 1434585600, 1434672000, 1434758400, 1434844800, 1434931200,
1435017600, 1435104000, 1435190400, 1435276800, 1435363200, 1435449600,
1435536000, 1435622400, 1435708800, 1435795200, 1435881600, 1435968000,
1436054400, 1436140800, 1436227200, 1436313600, 1436400000, 1436486400,
1436572800, 1436659200, 1436745600, 1436832000, 1436918400, 1437004800,
1437091200, 1437177600, 1437264000, 1437350400, 1437436800, 1437523200,
1437609600, 1437696000, 1437782400, 1437868800, 1437955200, 1438041600,
1438128000, 1438214400, 1438300800, 1438387200, 1438473600, 1438560000,
1438646400, 1438732800, 1438819200, 1438905600, 1438992000, 1439078400,
1439164800, 1439251200, 1439337600, 1439424000, 1439510400, 1439596800,
1439683200, 1439769600, 1439856000, 1439942400, 1440028800, 1440115200,
1440201600, 1440288000, 1440374400, 1440460800, 1440547200, 1440633600,
1440720000, 1440806400, 1440892800, 1440979200, 1441065600, 1441152000,
1441238400, 1441324800, 1441411200, 1441497600, 1441584000, 1441670400,
1441756800, 1441843200, 1441929600, 1442016000, 1442102400, 1442188800,
1442275200, 1442361600, 1442448000, 1442534400, 1442620800, 1442707200,
1442793600, 1442880000, 1442966400, 1443052800, 1443139200, 1443225600,
1443312000, 1443398400, 1443484800, 1443571200, 1443657600, 1443744000,
1443830400, 1443916800, 1444003200, 1444089600, 1444176000, 1444262400,
1444348800, 1444435200, 1444521600, 1444608000, 1444694400, 1444780800,
1444867200, 1444953600, 1445040000, 1445126400, 1445212800, 1445299200,
1445385600, 1445472000, 1445558400, 1445644800, 1445731200, 1445817600,
1445904000, 1445990400, 1446076800, 1446163200, 1446249600, 1446336000,
1446422400, 1446508800, 1446595200, 1446681600, 1446768000, 1446854400,
1446940800, 1447027200, 1447113600, 1447200000, 1447286400, 1447372800,
1447459200, 1447545600, 1447632000, 1447718400, 1447804800, 1447891200,
1447977600, 1448064000, 1448150400, 1448236800, 1448323200, 1448409600,
1448496000, 1448582400, 1448668800, 1448755200, 1448841600, 1448928000,
1449014400, 1449100800, 1449187200, 1449273600, 1449360000, 1449446400,
1449532800, 1449619200, 1449705600, 1449792000, 1449878400, 1449964800,
1450051200, 1450137600, 1450224000, 1450310400, 1450396800, 1450483200,
1450569600, 1450656000, 1450742400, 1450828800, 1450915200, 1451001600,
1451174400, 1451260800, 1451347200, 1451433600), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), Volume = c(2224.5, 44.3, 1835.4, 22205.2,
1100.9, 1409.7, 4233.9, 1857.5, 0.5, 1378.6, 1917.7, 4438.1,
73314, 1929.7, 666.9, 26.4, 1331.7, 7182.9, 2902.4, 22501.5,
2632.9, 1301.7, 102, 3673.7, 3446.7, 24917.2, 3867.7, 3977.5,
1780.7, 13.2, 2762.6, 5084.2, 3071.9, 4674, 4061.2, 2567.3, 216.5,
3323.7, 16072.4, 2108.4, 2786.2, 2883.9, 1848, 50.2, 2884.5,
9099.1, 4772.4, 2814.2, 2507.8, 1532.9, 2, 2932.5, 5734.1, 3077.1,
4960.5, 4289.3, 39098.7, 42.7, 1688.5, 3714.8, 6161.5, 4288.6,
25189, 2376.3, 18.4, 2530.1, 28803.4, 4369.3, 7202.6, 3500.1,
1880.4, 1705.5, 1541.4, 10804.1, 3712.7, 3182.5, 3527.6, 2266.8,
123.5, 2721.4, 5698, 8242.8, 4526.2, 13216.9, 1666.8, 61.8, 1596.4,
3999, 2026.6, 8054.1, 7198.6, 1754.9, 9.7, 44.4, 2837.6, 3479.5,
5583.3, 2247.9, 11005.5, 112, 614.1, 3668.8, 2464.6, 2156.6,
2086, 854.2, 90.1, 673.2, 18881.6, 2561.1, 11970.8, 2405.9, 1322.4,
226.2, 900.7, 1119.4, 3307.2, 10196, 2721.7, 27680.5, 7.4, 1130.1,
5506.6, 4332.5, 4490, 3839.1, 3902.9, 160.1, 1335.7, 13019.7,
1928.8, 2770.7, 58916.9, 200.6, 1759.9, 5744.1, 4217.8, 1734.2,
2385.6, 2810.8, 2409.8, 616.3, 2927.8, 1196.8, 4121.3, 18369.2,
2028, 3970, 1653.5, 8414.8, 3273.6, 2806.7, 3887.8, 1921, 3088.3,
1969.7, 1570.6, 3932.8, 16083.7, 4239.9, 2512.2, 2256.3, 618.8,
2312.8, 3129.2, 2973.7, 3311, 1889.8, 4972.5, 1871.8, 1480.9,
3875.4, 2899.1, 3199.6, 1227.6, 22825.8, 1704.6, 2799.4, 2039.6,
1579.7, 4847.7, 1284.8, 68.7, 1506.6, 18901.3, 13065.2, 30693.9,
4664.7, 4345, 11.6, 519.9, 2128.6, 4278.8, 2287.6, 2350.6, 577.7,
5.5, 987.8, 11598.7, 3479.5, 195.2, 5739.5, 2712.7, 45.6, 209.2,
5504.3, 2638.1, 1502.4, 2591.6, 983.5, 47.2, 556.9, 6807.1, 3577.6,
1790.5, 3795.6, 2223.6, 37.7, 599.7, 3029.7, 3722.8, 3904.5,
3650.1, 1190.3, 100.6, 605.9, 2981.2, 2090.1, 1876.7, 2296.2,
1013.7, 49.8, 421.3, 3973.4, 3028.6, 2808.4, 3595.6, 1450, 43.4,
914.4, 4933.7, 3790.2, 1735.5, 2675.1, 1211.9, 48, 1134.9, 3888.2,
5568.9, 3657.6, 7268.8, 2565.8, 44.1, 509.6, 56995.8, 2383.3,
1789.9, 4338.9, 2458.1, 63.4, 1073.7, 4398.2, 3822.8, 879, 2079,
2036.6, 216.6, 633.8, 9265.2, 1682.8, 1500.9, 3907.3, 2813.5,
17, 4582.7, 9989.6, 3588.3, 5064.6, 97352.7, 1892.3, 54, 1141.1,
10532.7, 9683, 19452.3, 4151.3, 2243, 33.7, 2208.9, 6159.6, 5811.6,
54718, 4610.5, 3598.8, 167.3, 8045.6, 6464.1, 3895.1, 3857.8,
4043.6, 2080.8, 350.4, 16011.2, 7012.4, 4329.9, 4554.6, 7454.4,
4379, 49.9, 2446.7, 32326.9, 28430.4, 11898.1, 11953.9, 3514.7,
74.3, 7928.2, 2188.7, 1895.9, 2113.7, 4400.2, 2367, 10, 2460,
2607.7, 14809.5, 2594.6, 2670.7, 3387.4, 26.2, 2321.6, 2555.1,
2302, 17930.3, 5320.1, 1865.2, 69, 3560.6, 1396.6, 3248, 2639.1,
4639.1, 327.2, 177.8, 3518.4, 3120.7, 4778.8, 4848.4, 2806.6,
3855.5, 1.7, 4524.5, 2473.7, 4024.4, 2574.3, 1350.6, 2.9, 703.1,
940.7, 9048.1, 164.2)), .Names = c("Date", "Volume"), row.names = c(NA,
-361L), class = "data.frame")

Related

R - Data Frame Forward and Backward Fill

I have a data frame and am trying to fill the missing values with the previous and next values in the data frame. I used the following code, but it did not fill and returns missing values still. I tried 2 different variations, but both do not work. Could someone please let me know what I am doing wrong? Thanks!
Data frame: 'oil.csv'
date dcoilwtico
1/1/13
1/2/13 93.14
1/3/13 92.97
1/4/13 93.12
1/7/13 93.2
1/8/13 93.21
1/9/13 93.08
1/10/13 93.81
1/11/13 93.6
1/14/13 94.27
1/15/13 93.26
1/16/13 94.28
1/17/13 95.49
1/18/13 95.61
1/21/13
1/22/13 96.09
dput(oil_df):
structure(list(date = c("2013-01-01", "2013-01-02", "2013-01-03",
"2013-01-04", "2013-01-07", "2013-01-08", "2013-01-09", "2013-01-10",
"2013-01-11", "2013-01-14", "2013-01-15", "2013-01-16", "2013-01-17",
"2013-01-18", "2013-01-21", "2013-01-22", "2013-01-23", "2013-01-24",
"2013-01-25", "2013-01-28", "2013-01-29", "2013-01-30", "2013-01-31",
"2013-02-01", "2013-02-04", "2013-02-05", "2013-02-06", "2013-02-07",
"2013-02-08", "2013-02-11", "2013-02-12", "2013-02-13", "2013-02-14",
"2013-02-15", "2013-02-18", "2013-02-19", "2013-02-20", "2013-02-21",
"2013-02-22", "2013-02-25", "2013-02-26", "2013-02-27", "2013-02-28",
"2013-03-01", "2013-03-04", "2013-03-05", "2013-03-06", "2013-03-07",
"2013-03-08", "2013-03-11", "2013-03-12", "2013-03-13", "2013-03-14",
"2013-03-15", "2013-03-18", "2013-03-19", "2013-03-20", "2013-03-21",
"2013-03-22", "2013-03-25", "2013-03-26", "2013-03-27", "2013-03-28",
"2013-03-29", "2013-04-01", "2013-04-02", "2013-04-03", "2013-04-04",
"2013-04-05", "2013-04-08", "2013-04-09", "2013-04-10", "2013-04-11",
"2013-04-12", "2013-04-15", "2013-04-16", "2013-04-17", "2013-04-18",
"2013-04-19", "2013-04-22", "2013-04-23", "2013-04-24", "2013-04-25",
"2013-04-26", "2013-04-29", "2013-04-30", "2013-05-01", "2013-05-02",
"2013-05-03", "2013-05-06", "2013-05-07", "2013-05-08", "2013-05-09",
"2013-05-10", "2013-05-13", "2013-05-14", "2013-05-15", "2013-05-16",
"2013-05-17", "2013-05-20", "2013-05-21", "2013-05-22", "2013-05-23",
"2013-05-24", "2013-05-27", "2013-05-28", "2013-05-29", "2013-05-30",
"2013-05-31", "2013-06-03", "2013-06-04", "2013-06-05", "2013-06-06",
"2013-06-07", "2013-06-10", "2013-06-11", "2013-06-12", "2013-06-13",
"2013-06-14", "2013-06-17", "2013-06-18", "2013-06-19", "2013-06-20",
"2013-06-21", "2013-06-24", "2013-06-25", "2013-06-26", "2013-06-27",
"2013-06-28", "2013-07-01", "2013-07-02", "2013-07-03", "2013-07-04",
"2013-07-05", "2013-07-08", "2013-07-09", "2013-07-10", "2013-07-11",
"2013-07-12", "2013-07-15", "2013-07-16", "2013-07-17", "2013-07-18",
"2013-07-19", "2013-07-22", "2013-07-23", "2013-07-24", "2013-07-25",
"2013-07-26", "2013-07-29", "2013-07-30", "2013-07-31", "2013-08-01",
"2013-08-02", "2013-08-05", "2013-08-06", "2013-08-07", "2013-08-08",
"2013-08-09", "2013-08-12", "2013-08-13", "2013-08-14", "2013-08-15",
"2013-08-16", "2013-08-19", "2013-08-20", "2013-08-21", "2013-08-22",
"2013-08-23", "2013-08-26", "2013-08-27", "2013-08-28", "2013-08-29",
"2013-08-30", "2013-09-02", "2013-09-03", "2013-09-04", "2013-09-05",
"2013-09-06", "2013-09-09", "2013-09-10", "2013-09-11", "2013-09-12",
"2013-09-13", "2013-09-16", "2013-09-17", "2013-09-18", "2013-09-19",
"2013-09-20", "2013-09-23", "2013-09-24", "2013-09-25", "2013-09-26",
"2013-09-27", "2013-09-30", "2013-10-01", "2013-10-02", "2013-10-03",
"2013-10-04", "2013-10-07", "2013-10-08", "2013-10-09", "2013-10-10",
"2013-10-11", "2013-10-14", "2013-10-15", "2013-10-16", "2013-10-17",
"2013-10-18", "2013-10-21", "2013-10-22", "2013-10-23", "2013-10-24",
"2013-10-25", "2013-10-28", "2013-10-29", "2013-10-30", "2013-10-31",
"2013-11-01", "2013-11-04", "2013-11-05", "2013-11-06", "2013-11-07",
"2013-11-08", "2013-11-11", "2013-11-12", "2013-11-13", "2013-11-14",
"2013-11-15", "2013-11-18", "2013-11-19", "2013-11-20", "2013-11-21",
"2013-11-22", "2013-11-25", "2013-11-26", "2013-11-27", "2013-11-28",
"2013-11-29", "2013-12-02", "2013-12-03", "2013-12-04", "2013-12-05",
"2013-12-06", "2013-12-09", "2013-12-10", "2013-12-11", "2013-12-12",
"2013-12-13", "2013-12-16", "2013-12-17", "2013-12-18", "2013-12-19",
"2013-12-20", "2013-12-23", "2013-12-24", "2013-12-25", "2013-12-26",
"2013-12-27", "2013-12-30", "2013-12-31", "2014-01-01", "2014-01-02",
"2014-01-03", "2014-01-06", "2014-01-07", "2014-01-08", "2014-01-09",
"2014-01-10", "2014-01-13", "2014-01-14", "2014-01-15", "2014-01-16",
"2014-01-17", "2014-01-20", "2014-01-21", "2014-01-22", "2014-01-23",
"2014-01-24", "2014-01-27", "2014-01-28", "2014-01-29", "2014-01-30",
"2014-01-31", "2014-02-03", "2014-02-04", "2014-02-05", "2014-02-06",
"2014-02-07", "2014-02-10", "2014-02-11", "2014-02-12", "2014-02-13",
"2014-02-14", "2014-02-17", "2014-02-18", "2014-02-19", "2014-02-20",
"2014-02-21", "2014-02-24", "2014-02-25", "2014-02-26", "2014-02-27",
"2014-02-28", "2014-03-03", "2014-03-04", "2014-03-05", "2014-03-06",
"2014-03-07", "2014-03-10", "2014-03-11", "2014-03-12", "2014-03-13",
"2014-03-14", "2014-03-17", "2014-03-18", "2014-03-19", "2014-03-20",
"2014-03-21", "2014-03-24", "2014-03-25", "2014-03-26", "2014-03-27",
"2014-03-28", "2014-03-31", "2014-04-01", "2014-04-02", "2014-04-03",
"2014-04-04", "2014-04-07", "2014-04-08", "2014-04-09", "2014-04-10",
"2014-04-11", "2014-04-14", "2014-04-15", "2014-04-16", "2014-04-17",
"2014-04-18", "2014-04-21", "2014-04-22", "2014-04-23", "2014-04-24",
"2014-04-25", "2014-04-28", "2014-04-29", "2014-04-30", "2014-05-01",
"2014-05-02", "2014-05-05", "2014-05-06", "2014-05-07", "2014-05-08",
"2014-05-09", "2014-05-12", "2014-05-13", "2014-05-14", "2014-05-15",
"2014-05-16", "2014-05-19", "2014-05-20", "2014-05-21", "2014-05-22",
"2014-05-23", "2014-05-26", "2014-05-27", "2014-05-28", "2014-05-29",
"2014-05-30", "2014-06-02", "2014-06-03", "2014-06-04", "2014-06-05",
"2014-06-06", "2014-06-09", "2014-06-10", "2014-06-11", "2014-06-12",
"2014-06-13", "2014-06-16", "2014-06-17", "2014-06-18", "2014-06-19",
"2014-06-20", "2014-06-23", "2014-06-24", "2014-06-25", "2014-06-26",
"2014-06-27", "2014-06-30", "2014-07-01", "2014-07-02", "2014-07-03",
"2014-07-04", "2014-07-07", "2014-07-08", "2014-07-09", "2014-07-10",
"2014-07-11", "2014-07-14", "2014-07-15", "2014-07-16", "2014-07-17",
"2014-07-18", "2014-07-21", "2014-07-22", "2014-07-23", "2014-07-24",
"2014-07-25", "2014-07-28", "2014-07-29", "2014-07-30", "2014-07-31",
"2014-08-01", "2014-08-04", "2014-08-05", "2014-08-06", "2014-08-07",
"2014-08-08", "2014-08-11", "2014-08-12", "2014-08-13", "2014-08-14",
"2014-08-15", "2014-08-18", "2014-08-19", "2014-08-20", "2014-08-21",
"2014-08-22", "2014-08-25", "2014-08-26", "2014-08-27", "2014-08-28",
"2014-08-29", "2014-09-01", "2014-09-02", "2014-09-03", "2014-09-04",
"2014-09-05", "2014-09-08", "2014-09-09", "2014-09-10", "2014-09-11",
"2014-09-12", "2014-09-15", "2014-09-16", "2014-09-17", "2014-09-18",
"2014-09-19", "2014-09-22", "2014-09-23", "2014-09-24", "2014-09-25",
"2014-09-26", "2014-09-29", "2014-09-30", "2014-10-01", "2014-10-02",
"2014-10-03", "2014-10-06", "2014-10-07", "2014-10-08", "2014-10-09",
"2014-10-10", "2014-10-13", "2014-10-14", "2014-10-15", "2014-10-16",
"2014-10-17", "2014-10-20", "2014-10-21", "2014-10-22", "2014-10-23",
"2014-10-24", "2014-10-27", "2014-10-28", "2014-10-29", "2014-10-30",
"2014-10-31", "2014-11-03", "2014-11-04", "2014-11-05", "2014-11-06",
"2014-11-07", "2014-11-10", "2014-11-11", "2014-11-12", "2014-11-13",
"2014-11-14", "2014-11-17", "2014-11-18", "2014-11-19", "2014-11-20",
"2014-11-21", "2014-11-24", "2014-11-25", "2014-11-26", "2014-11-27",
"2014-11-28", "2014-12-01", "2014-12-02", "2014-12-03", "2014-12-04",
"2014-12-05", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11",
"2014-12-12", "2014-12-15", "2014-12-16", "2014-12-17", "2014-12-18",
"2014-12-19", "2014-12-22", "2014-12-23", "2014-12-24", "2014-12-25",
"2014-12-26", "2014-12-29", "2014-12-30", "2014-12-31", "2015-01-01",
"2015-01-02", "2015-01-05", "2015-01-06", "2015-01-07", "2015-01-08",
"2015-01-09", "2015-01-12", "2015-01-13", "2015-01-14", "2015-01-15",
"2015-01-16", "2015-01-19", "2015-01-20", "2015-01-21", "2015-01-22",
"2015-01-23", "2015-01-26", "2015-01-27", "2015-01-28", "2015-01-29",
"2015-01-30", "2015-02-02", "2015-02-03", "2015-02-04", "2015-02-05",
"2015-02-06", "2015-02-09", "2015-02-10", "2015-02-11", "2015-02-12",
"2015-02-13", "2015-02-16", "2015-02-17", "2015-02-18", "2015-02-19",
"2015-02-20", "2015-02-23", "2015-02-24", "2015-02-25", "2015-02-26",
"2015-02-27", "2015-03-02", "2015-03-03", "2015-03-04", "2015-03-05",
"2015-03-06", "2015-03-09", "2015-03-10", "2015-03-11", "2015-03-12",
"2015-03-13", "2015-03-16", "2015-03-17", "2015-03-18", "2015-03-19",
"2015-03-20", "2015-03-23", "2015-03-24", "2015-03-25", "2015-03-26",
"2015-03-27", "2015-03-30", "2015-03-31", "2015-04-01", "2015-04-02",
"2015-04-03", "2015-04-06", "2015-04-07", "2015-04-08", "2015-04-09",
"2015-04-10", "2015-04-13", "2015-04-14", "2015-04-15", "2015-04-16",
"2015-04-17", "2015-04-20", "2015-04-21", "2015-04-22", "2015-04-23",
"2015-04-24", "2015-04-27", "2015-04-28", "2015-04-29", "2015-04-30",
"2015-05-01", "2015-05-04", "2015-05-05", "2015-05-06", "2015-05-07",
"2015-05-08", "2015-05-11", "2015-05-12", "2015-05-13", "2015-05-14",
"2015-05-15", "2015-05-18", "2015-05-19", "2015-05-20", "2015-05-21",
"2015-05-22", "2015-05-25", "2015-05-26", "2015-05-27", "2015-05-28",
"2015-05-29", "2015-06-01", "2015-06-02", "2015-06-03", "2015-06-04",
"2015-06-05", "2015-06-08", "2015-06-09", "2015-06-10", "2015-06-11",
"2015-06-12", "2015-06-15", "2015-06-16", "2015-06-17", "2015-06-18",
"2015-06-19", "2015-06-22", "2015-06-23", "2015-06-24", "2015-06-25",
"2015-06-26", "2015-06-29", "2015-06-30", "2015-07-01", "2015-07-02",
"2015-07-03", "2015-07-06", "2015-07-07", "2015-07-08", "2015-07-09",
"2015-07-10", "2015-07-13", "2015-07-14", "2015-07-15", "2015-07-16",
"2015-07-17", "2015-07-20", "2015-07-21", "2015-07-22", "2015-07-23",
"2015-07-24", "2015-07-27", "2015-07-28", "2015-07-29", "2015-07-30",
"2015-07-31", "2015-08-03", "2015-08-04", "2015-08-05", "2015-08-06",
"2015-08-07", "2015-08-10", "2015-08-11", "2015-08-12", "2015-08-13",
"2015-08-14", "2015-08-17", "2015-08-18", "2015-08-19", "2015-08-20",
"2015-08-21", "2015-08-24", "2015-08-25", "2015-08-26", "2015-08-27",
"2015-08-28", "2015-08-31", "2015-09-01", "2015-09-02", "2015-09-03",
"2015-09-04", "2015-09-07", "2015-09-08", "2015-09-09", "2015-09-10",
"2015-09-11", "2015-09-14", "2015-09-15", "2015-09-16", "2015-09-17",
"2015-09-18", "2015-09-21", "2015-09-22", "2015-09-23", "2015-09-24",
"2015-09-25", "2015-09-28", "2015-09-29", "2015-09-30", "2015-10-01",
"2015-10-02", "2015-10-05", "2015-10-06", "2015-10-07", "2015-10-08",
"2015-10-09", "2015-10-12", "2015-10-13", "2015-10-14", "2015-10-15",
"2015-10-16", "2015-10-19", "2015-10-20", "2015-10-21", "2015-10-22",
"2015-10-23", "2015-10-26", "2015-10-27", "2015-10-28", "2015-10-29",
"2015-10-30", "2015-11-02", "2015-11-03", "2015-11-04", "2015-11-05",
"2015-11-06", "2015-11-09", "2015-11-10", "2015-11-11", "2015-11-12",
"2015-11-13", "2015-11-16", "2015-11-17", "2015-11-18", "2015-11-19",
"2015-11-20", "2015-11-23", "2015-11-24", "2015-11-25", "2015-11-26",
"2015-11-27", "2015-11-30", "2015-12-01", "2015-12-02", "2015-12-03",
"2015-12-04", "2015-12-07", "2015-12-08", "2015-12-09", "2015-12-10",
"2015-12-11", "2015-12-14", "2015-12-15", "2015-12-16", "2015-12-17",
"2015-12-18", "2015-12-21", "2015-12-22", "2015-12-23", "2015-12-24",
"2015-12-25", "2015-12-28", "2015-12-29", "2015-12-30", "2015-12-31",
"2016-01-01", "2016-01-04", "2016-01-05", "2016-01-06", "2016-01-07",
"2016-01-08", "2016-01-11", "2016-01-12", "2016-01-13", "2016-01-14",
"2016-01-15", "2016-01-18", "2016-01-19", "2016-01-20", "2016-01-21",
"2016-01-22", "2016-01-25", "2016-01-26", "2016-01-27", "2016-01-28",
"2016-01-29", "2016-02-01", "2016-02-02", "2016-02-03", "2016-02-04",
"2016-02-05", "2016-02-08", "2016-02-09", "2016-02-10", "2016-02-11",
"2016-02-12", "2016-02-15", "2016-02-16", "2016-02-17", "2016-02-18",
"2016-02-19", "2016-02-22", "2016-02-23", "2016-02-24", "2016-02-25",
"2016-02-26", "2016-02-29", "2016-03-01", "2016-03-02", "2016-03-03",
"2016-03-04", "2016-03-07", "2016-03-08", "2016-03-09", "2016-03-10",
"2016-03-11", "2016-03-14", "2016-03-15", "2016-03-16", "2016-03-17",
"2016-03-18", "2016-03-21", "2016-03-22", "2016-03-23", "2016-03-24",
"2016-03-25", "2016-03-28", "2016-03-29", "2016-03-30", "2016-03-31",
"2016-04-01", "2016-04-04", "2016-04-05", "2016-04-06", "2016-04-07",
"2016-04-08", "2016-04-11", "2016-04-12", "2016-04-13", "2016-04-14",
"2016-04-15", "2016-04-18", "2016-04-19", "2016-04-20", "2016-04-21",
"2016-04-22", "2016-04-25", "2016-04-26", "2016-04-27", "2016-04-28",
"2016-04-29", "2016-05-02", "2016-05-03", "2016-05-04", "2016-05-05",
"2016-05-06", "2016-05-09", "2016-05-10", "2016-05-11", "2016-05-12",
"2016-05-13", "2016-05-16", "2016-05-17", "2016-05-18", "2016-05-19",
"2016-05-20", "2016-05-23", "2016-05-24", "2016-05-25", "2016-05-26",
"2016-05-27", "2016-05-30", "2016-05-31", "2016-06-01", "2016-06-02",
"2016-06-03", "2016-06-06", "2016-06-07", "2016-06-08", "2016-06-09",
"2016-06-10", "2016-06-13", "2016-06-14", "2016-06-15", "2016-06-16",
"2016-06-17", "2016-06-20", "2016-06-21", "2016-06-22", "2016-06-23",
"2016-06-24", "2016-06-27", "2016-06-28", "2016-06-29", "2016-06-30",
"2016-07-01", "2016-07-04", "2016-07-05", "2016-07-06", "2016-07-07",
"2016-07-08", "2016-07-11", "2016-07-12", "2016-07-13", "2016-07-14",
"2016-07-15", "2016-07-18", "2016-07-19", "2016-07-20", "2016-07-21",
"2016-07-22", "2016-07-25", "2016-07-26", "2016-07-27", "2016-07-28",
"2016-07-29", "2016-08-01", "2016-08-02", "2016-08-03", "2016-08-04",
"2016-08-05", "2016-08-08", "2016-08-09", "2016-08-10", "2016-08-11",
"2016-08-12", "2016-08-15", "2016-08-16", "2016-08-17", "2016-08-18",
"2016-08-19", "2016-08-22", "2016-08-23", "2016-08-24", "2016-08-25",
"2016-08-26", "2016-08-29", "2016-08-30", "2016-08-31", "2016-09-01",
"2016-09-02", "2016-09-05", "2016-09-06", "2016-09-07", "2016-09-08",
"2016-09-09", "2016-09-12", "2016-09-13", "2016-09-14", "2016-09-15",
"2016-09-16", "2016-09-19", "2016-09-20", "2016-09-21", "2016-09-22",
"2016-09-23", "2016-09-26", "2016-09-27", "2016-09-28", "2016-09-29",
"2016-09-30", "2016-10-03", "2016-10-04", "2016-10-05", "2016-10-06",
"2016-10-07", "2016-10-10", "2016-10-11", "2016-10-12", "2016-10-13",
"2016-10-14", "2016-10-17", "2016-10-18", "2016-10-19", "2016-10-20",
"2016-10-21", "2016-10-24", "2016-10-25", "2016-10-26", "2016-10-27",
"2016-10-28", "2016-10-31", "2016-11-01", "2016-11-02", "2016-11-03",
"2016-11-04", "2016-11-07", "2016-11-08", "2016-11-09", "2016-11-10",
"2016-11-11", "2016-11-14", "2016-11-15", "2016-11-16", "2016-11-17",
"2016-11-18", "2016-11-21", "2016-11-22", "2016-11-23", "2016-11-24",
"2016-11-25", "2016-11-28", "2016-11-29", "2016-11-30", "2016-12-01",
"2016-12-02", "2016-12-05", "2016-12-06", "2016-12-07", "2016-12-08",
"2016-12-09", "2016-12-12", "2016-12-13", "2016-12-14", "2016-12-15",
"2016-12-16", "2016-12-19", "2016-12-20", "2016-12-21", "2016-12-22",
"2016-12-23", "2016-12-26", "2016-12-27", "2016-12-28", "2016-12-29",
"2016-12-30", "2017-01-02", "2017-01-03", "2017-01-04", "2017-01-05",
"2017-01-06", "2017-01-09", "2017-01-10", "2017-01-11", "2017-01-12",
"2017-01-13", "2017-01-16", "2017-01-17", "2017-01-18", "2017-01-19",
"2017-01-20", "2017-01-23", "2017-01-24", "2017-01-25", "2017-01-26",
"2017-01-27", "2017-01-30", "2017-01-31", "2017-02-01", "2017-02-02",
"2017-02-03", "2017-02-06", "2017-02-07", "2017-02-08", "2017-02-09",
"2017-02-10", "2017-02-13", "2017-02-14", "2017-02-15", "2017-02-16",
"2017-02-17", "2017-02-20", "2017-02-21", "2017-02-22", "2017-02-23",
"2017-02-24", "2017-02-27", "2017-02-28", "2017-03-01", "2017-03-02",
"2017-03-03", "2017-03-06", "2017-03-07", "2017-03-08", "2017-03-09",
"2017-03-10", "2017-03-13", "2017-03-14", "2017-03-15", "2017-03-16",
"2017-03-17", "2017-03-20", "2017-03-21", "2017-03-22", "2017-03-23",
"2017-03-24", "2017-03-27", "2017-03-28", "2017-03-29", "2017-03-30",
"2017-03-31", "2017-04-03", "2017-04-04", "2017-04-05", "2017-04-06",
"2017-04-07", "2017-04-10", "2017-04-11", "2017-04-12", "2017-04-13",
"2017-04-14", "2017-04-17", "2017-04-18", "2017-04-19", "2017-04-20",
"2017-04-21", "2017-04-24", "2017-04-25", "2017-04-26", "2017-04-27",
"2017-04-28", "2017-05-01", "2017-05-02", "2017-05-03", "2017-05-04",
"2017-05-05", "2017-05-08", "2017-05-09", "2017-05-10", "2017-05-11",
"2017-05-12", "2017-05-15", "2017-05-16", "2017-05-17", "2017-05-18",
"2017-05-19", "2017-05-22", "2017-05-23", "2017-05-24", "2017-05-25",
"2017-05-26", "2017-05-29", "2017-05-30", "2017-05-31", "2017-06-01",
"2017-06-02", "2017-06-05", "2017-06-06", "2017-06-07", "2017-06-08",
"2017-06-09", "2017-06-12", "2017-06-13", "2017-06-14", "2017-06-15",
"2017-06-16", "2017-06-19", "2017-06-20", "2017-06-21", "2017-06-22",
"2017-06-23", "2017-06-26", "2017-06-27", "2017-06-28", "2017-06-29",
"2017-06-30", "2017-07-03", "2017-07-04", "2017-07-05", "2017-07-06",
"2017-07-07", "2017-07-10", "2017-07-11", "2017-07-12", "2017-07-13",
"2017-07-14", "2017-07-17", "2017-07-18", "2017-07-19", "2017-07-20",
"2017-07-21", "2017-07-24", "2017-07-25", "2017-07-26", "2017-07-27",
"2017-07-28", "2017-07-31", "2017-08-01", "2017-08-02", "2017-08-03",
"2017-08-04", "2017-08-07", "2017-08-08", "2017-08-09", "2017-08-10",
"2017-08-11", "2017-08-14", "2017-08-15", "2017-08-16", "2017-08-17",
"2017-08-18", "2017-08-21", "2017-08-22", "2017-08-23", "2017-08-24",
"2017-08-25", "2017-08-28", "2017-08-29", "2017-08-30", "2017-08-31"
), dcoilwtico = c(NA, 93.14, 92.97, 93.12, 93.2, 93.21, 93.08,
93.81, 93.6, 94.27, 93.26, 94.28, 95.49, 95.61, NA, 96.09, 95.06,
95.35, 95.15, 95.95, 97.62, 97.98, 97.65, 97.46, 96.21, 96.68,
96.44, 95.84, 95.71, 97.01, 97.48, 97.03, 97.3, 95.95, NA, 96.69,
94.92, 92.79, 93.12, 92.74, 92.63, 92.84, 92.03, 90.71, 90.13,
90.88, 90.47, 91.53, 92.01, 92.07, 92.44, 92.47, 93.03, 93.49,
93.71, 92.44, 93.21, 92.46, 93.41, 94.55, 95.99, 96.53, 97.24,
NA, 97.1, 97.23, 95.02, 93.26, 92.76, 93.36, 94.18, 94.59, 93.44,
91.23, 88.75, 88.73, 86.65, 87.83, 88.04, 88.81, 89.21, 91.07,
93.27, 92.63, 94.09, 93.22, 90.74, 93.7, 95.25, 95.8, 95.28,
96.24, 96.09, 95.81, 94.76, 93.96, 93.95, 94.85, 95.72, 96.29,
95.55, 93.98, 94.12, 93.84, NA, 94.65, 93.13, 93.57, 91.93, 93.41,
93.36, 93.66, 94.71, 96.11, 95.82, 95.5, 95.98, 96.66, 97.83,
97.86, 98.46, 98.24, 94.89, 93.81, 95.07, 95.25, 95.47, 97, 96.36,
97.94, 99.65, 101.92, NA, 103.09, 103.03, 103.46, 106.41, 104.77,
105.85, 106.2, 105.88, 106.39, 107.94, 108, 106.61, 107.13, 105.41,
105.47, 104.76, 104.61, 103.14, 105.1, 107.93, 106.94, 106.61,
105.32, 104.41, 103.45, 106.04, 106.19, 106.78, 106.89, 107.43,
107.58, 107.14, 104.9, 103.93, 104.93, 106.48, 105.88, 109.11,
110.17, 108.51, 107.98, NA, 108.67, 107.29, 108.5, 110.62, 109.62,
107.48, 107.65, 108.72, 108.31, 106.54, 105.36, 108.23, 106.26,
104.7, 103.62, 103.22, 102.68, 103.1, 102.86, 102.36, 102.09,
104.15, 103.29, 103.83, 103.07, 103.54, 101.63, 103.08, 102.17,
102.46, 101.15, 102.34, 100.72, 100.87, 99.28, 97.63, 96.9, 96.65,
97.4, 98.74, 98.29, 96.81, 96.29, 94.56, 94.58, 93.4, 94.74,
94.25, 94.56, 95.13, 93.12, 93.91, 93.76, 93.8, 93.03, 93.35,
93.34, 95.35, 94.53, 93.86, 93.41, 92.05, NA, 92.55, 93.61, 95.83,
96.97, 97.14, 97.48, 97.1, 98.32, 97.25, 97.21, 96.27, 97.18,
96.99, 97.59, 98.4, 99.11, 98.62, 98.87, NA, 99.18, 99.94, 98.9,
98.17, NA, 95.14, 93.66, 93.12, 93.31, 91.9, 91.36, 92.39, 91.45,
92.15, 93.78, 93.54, 93.96, NA, 94.51, 96.35, 97.23, 96.66, 95.82,
97.49, 97.34, 98.25, 97.55, 96.44, 97.24, 97.4, 97.84, 99.98,
100.12, 99.96, 100.38, 100.27, 100.31, NA, 102.54, 103.46, 103.2,
102.53, 103.17, 102.2, 102.93, 102.68, 102.88, 105.34, 103.64,
101.75, 101.82, 102.82, 101.39, 100.29, 98.29, 98.57, 99.23,
98.43, 100.08, 100.71, 99.68, 99.97, 100.05, 99.66, 100.61, 101.25,
101.73, 101.57, 99.69, 99.6, 100.29, 101.16, 100.43, 102.57,
103.55, 103.37, 103.68, 104.05, 103.7, 103.71, 104.33, NA, 104.35,
101.69, 101.47, 102.2, 100.85, 101.13, 101.56, 100.07, 99.69,
100.09, 99.74, 99.81, 101.06, 100.52, 100.32, 100.89, 102.01,
102.63, 101.74, 102.31, 102.95, 102.8, 104.31, 104.03, 105.01,
NA, 104.78, 103.37, 104.26, 103.4, 103.07, 103.34, 103.27, 103.17,
103.32, 105.09, 105.02, 105.04, 107.2, 107.49, 107.52, 106.95,
106.64, 107.08, 107.95, 106.83, 106.64, 107.04, 106.49, 106.46,
106.07, 106.06, 105.18, 104.76, NA, 104.19, 104.06, 102.93, 103.61,
101.48, 101.73, 100.56, 101.88, 103.84, 103.83, 105.34, 104.59,
103.81, 102.76, 105.23, 105.68, 104.91, 104.29, 98.23, 97.86,
98.26, 97.34, 96.93, 97.34, 97.61, 98.09, 97.36, 97.57, 95.54,
97.3, 96.44, 94.35, 96.4, 93.97, 93.61, 95.39, 95.78, 95.82,
96.44, 97.86, NA, 92.92, 95.5, 94.51, 93.32, 92.64, 92.73, 91.71,
92.89, 92.18, 92.86, 94.91, 94.33, 93.07, 92.43, 91.46, 91.55,
93.6, 93.59, 95.55, 94.53, 91.17, 90.74, 91.02, 89.76, 90.33,
88.89, 87.29, 85.76, 85.87, 85.73, 81.72, 81.82, 82.33, 82.8,
82.76, 83.25, 80.52, 82.81, 81.27, 81.26, 81.36, 82.25, 81.06,
80.53, 78.77, 77.15, 78.71, 77.87, 78.71, 77.43, 77.85, 77.16,
74.13, 75.91, 75.64, 74.55, 74.55, 75.63, 76.52, 75.74, 74.04,
73.7, NA, 65.94, 68.98, 66.99, 67.3, 66.73, 65.89, 63.13, 63.74,
60.99, 60.01, 57.81, 55.96, 55.97, 56.43, 54.18, 56.91, 55.25,
56.78, 55.7, NA, 54.59, 53.46, 54.14, 53.45, NA, 52.72, 50.05,
47.98, 48.69, 48.8, 48.35, 46.06, 45.92, 48.49, 46.37, 48.49,
NA, 46.79, 47.85, 45.93, 45.26, 44.8, 45.84, 44.08, 44.12, 47.79,
49.25, 53.04, 48.45, 50.48, 51.66, 52.99, 50.06, 48.8, 51.17,
52.66, NA, 53.56, 52.13, 51.12, 49.95, 49.56, 48.48, 50.25, 47.65,
49.84, 49.59, 50.43, 51.53, 50.76, 49.61, 49.95, 48.42, 48.06,
47.12, 44.88, 43.93, 43.39, 44.63, 44.02, 46, 47.4, 47.03, 48.75,
51.41, 48.83, 48.66, 47.72, 50.12, 49.13, NA, 52.08, 53.95, 50.44,
50.79, 51.63, 51.95, 53.3, 56.25, 56.69, 55.71, 56.37, 55.58,
56.17, 56.59, 55.98, 55.56, 57.05, 58.55, 59.62, 59.1, 58.92,
60.38, 60.93, 58.99, 59.41, 59.23, 60.72, 60.5, 59.89, 59.73,
59.44, 57.3, 58.96, 60.18, 58.88, NA, 57.29, 57.51, 57.69, 60.25,
60.24, 61.3, 59.67, 58, 59.11, 58.15, 60.15, 61.36, 60.74, 59.96,
59.53, 60.01, 59.89, 60.41, 59.62, 60.01, 61.05, 60.01, 59.59,
59.41, 58.34, 59.48, 56.94, 56.93, NA, 52.48, 52.33, 51.61, 52.76,
52.74, 52.19, 53.05, 51.4, 50.9, 50.88, 50.11, 50.59, 49.27,
48.11, 47.98, 47.17, 47.97, 48.77, 48.53, 47.11, 45.25, 45.75,
45.13, 44.69, 43.87, 44.94, 43.11, 43.22, 42.27, 42.45, 41.93,
42.58, 40.75, 41, 40.45, 38.22, 39.15, 38.5, 42.47, 45.29, 49.2,
45.38, 46.3, 46.75, 46.02, NA, 45.92, 44.13, 45.85, 44.75, 44.07,
44.58, 47.12, 46.93, 44.71, 46.67, 46.17, 44.53, 44.94, 45.55,
44.4, 45.24, 45.06, 44.75, 45.54, 46.28, 48.53, 47.86, 49.46,
49.67, 47.09, 46.7, 46.63, 46.38, 47.3, 45.91, 45.84, 45.22,
44.9, 43.91, 43.19, 43.21, 45.93, 46.02, 46.6, 46.12, 47.88,
46.32, 45.27, 44.32, 43.87, 44.23, 42.95, 41.74, 40.69, 41.68,
40.73, 40.75, 40.55, 39.39, 39.27, 40.89, 41.22, NA, 40.57, 40.43,
40.58, 39.93, 41.08, 40, 37.64, 37.46, 37.16, 36.76, 35.65, 36.31,
37.32, 35.55, 34.98, 34.72, 34.55, 36.12, 36.76, 37.62, NA, 36.36,
37.88, 36.59, 37.13, NA, 36.81, 35.97, 33.97, 33.29, 33.2, 31.42,
30.42, 30.42, 31.22, 29.45, NA, 28.47, 26.68, 29.55, 32.07, 30.31,
29.54, 32.32, 33.21, 33.66, 31.62, 29.9, 32.29, 31.63, 30.86,
29.71, 27.96, 27.54, 26.19, 29.32, NA, 29.05, 30.68, 30.77, 29.59,
31.37, 31.84, 30.35, 31.4, 31.65, 32.74, 34.39, 34.57, 34.56,
35.91, 37.9, 36.67, 37.62, 37.77, 38.51, 37.2, 36.32, 38.43,
40.17, 39.47, 39.91, 41.45, 38.28, 38.14, NA, 37.99, 36.91, 36.91,
36.94, 35.36, 34.3, 34.52, 37.74, 37.3, 39.74, 40.46, 42.12,
41.7, 41.45, 40.4, 39.74, 40.88, 42.72, 43.18, 42.76, 41.67,
42.52, 45.29, 46.03, 45.98, 44.75, 43.65, 43.77, 44.33, 44.58,
43.45, 44.68, 46.21, 46.64, 46.22, 47.72, 48.29, 48.12, 48.16,
47.67, 48.12, 48.04, 49.1, 49, 49.36, NA, 49.1, 49.07, 49.14,
48.69, 49.71, 50.37, 51.23, 50.52, 49.09, 48.89, 48.49, 47.92,
46.14, 48, 49.4, 48.95, 49.16, 49.34, 46.7, 45.8, 47.93, 49.85,
48.27, 49.02, NA, 46.73, 47.37, 45.22, 45.37, 44.73, 46.82, 44.87,
45.64, 45.93, 45.23, 44.64, 44.96, 43.96, 43.41, 42.4, 42.16,
41.9, 41.13, 41.54, 40.05, 39.5, 40.8, 41.92, 41.83, 43.06, 42.78,
41.75, 43.51, 44.47, 45.72, 46.57, 46.81, 48.2, 48.48, 46.8,
47.54, 46.29, 46.97, 47.64, 46.97, 46.32, 44.68, 43.17, 44.39,
NA, 44.85, 45.47, 47.63, 45.88, 46.28, 44.91, 43.62, 43.85, 43.04,
43.34, 43.85, 45.33, 46.1, 44.36, 45.6, 44.65, 47.07, 47.72,
47.72, 48.8, 48.67, 49.75, 50.44, 49.76, 49.76, 50.72, 50.14,
50.47, 50.35, 49.97, 50.3, 51.59, 50.31, 50.61, 50.18, 49.45,
48.75, 49.71, 48.72, 46.83, 46.66, 45.32, 44.66, 44.07, 44.88,
44.96, 45.2, 44.62, 43.39, 43.29, 45.86, 45.56, 45.37, 45.69,
47.48, 48.07, 46.72, NA, 46.72, 45.66, 45.29, 49.41, 51.08, 51.7,
51.72, 50.95, 49.85, 50.84, 51.51, 52.74, 52.99, 51.01, 50.9,
51.93, 52.13, 52.22, 51.44, 51.98, 52.01, NA, 52.82, 54.01, 53.8,
53.75, NA, 52.36, 53.26, 53.77, 53.98, 51.95, 50.82, 52.19, 53.01,
52.36, NA, 52.45, 51.12, 51.39, 52.33, 52.77, 52.38, 52.14, 53.24,
53.18, 52.63, 52.75, 53.9, 53.55, 53.81, 53.01, 52.19, 52.37,
52.99, 53.84, 52.96, 53.21, 53.11, 53.41, 53.41, NA, 54.02, 53.61,
54.48, 53.99, 54.04, 54, 53.82, 52.63, 53.33, 53.19, 52.68, 49.83,
48.75, 48.05, 47.95, 47.24, 48.34, 48.3, 48.34, 47.79, 47.02,
47.29, 47, 47.3, 47.02, 48.36, 49.47, 50.3, 50.54, 50.25, 50.99,
51.14, 51.69, 52.25, 53.06, 53.38, 53.12, 53.19, NA, 52.62, 52.46,
50.49, 50.26, 49.64, 48.9, 49.22, 49.22, 48.96, 49.31, 48.83,
47.65, 47.79, 45.55, 46.23, 46.46, 45.84, 47.28, 47.81, 47.83,
48.86, 48.64, 49.04, 49.36, 50.32, 50.81, 51.12, 50.99, 48.57,
49.58, NA, 49.63, 48.29, 48.32, 47.68, 47.4, 48.13, 45.8, 45.68,
45.82, 46.1, 46.41, 44.79, 44.47, 44.73, 44.24, 43.34, 42.48,
42.53, 42.86, 43.24, 44.25, 44.74, 44.88, 46.02, NA, NA, 45.11,
45.52, 44.25, 44.4, 45.06, 45.48, 46.06, 46.53, 46.02, 46.4,
47.1, 46.73, 45.78, 46.21, 47.77, 48.58, 49.05, 49.72, 50.21,
49.19, 49.6, 49.03, 49.57, 49.37, 49.07, 49.59, 48.54, 48.81,
47.59, 47.57, 46.8, 47.07, 48.59, 47.39, 47.65, 48.45, 47.24,
47.65, 46.4, 46.46, 45.96, 47.26)), class = "data.frame", row.names = c(NA,
-1218L))
Code:
# Tried both of these options, and both don't work
oil_df %>% fill(everything()) %>% fill(everything(), .direction = 'up')
na.locf(na.locf(oil_df), fromLast = TRUE)
# Confirm oil_df has no more missing values
sum(is.na(oil_df))
Output: Excepted 0
> na.locf(na.locf(oil_df), fromLast = TRUE)
>
> # Confirm oil_df has no more missing values
> sum(is.na(oil_df))
[1] 43
The problem with the code in the question is that it is calculating a result and then throwing it away and instead of checking the result it is checking the original data frame. Assign the result of the na.locf to a variable and then check that object. Also note that since there are no NA's on the end we can just use one na.locf if it is ok that the NA's get filled in with the next non-NA.
library(zoo)
oil_df2 <- na.locf(oil_df, fromLast = TRUE)
sum(is.na(oil_df2))
## [1] 0
You can use the downup parameter of fill() in the tidyr package :
Direction in which to fill missing values. Currently either "down" (the default), "up", "downup" (i.e. first down and then up) or "updown" (first up and then down)
df <- data.frame(
id = 1:10,
value = c(NA,100,runif(4,100,200),NA,runif(3,100,200))
)
id value
1 1 NA
2 2 100.0000
3 3 129.3819
4 4 137.7009
5 5 187.6759
6 6 155.0566
7 7 NA
8 8 125.9839
9 9 159.3502
10 10 129.0750
df <- df %>%
fill(value, .direction = "downup")
df
id value
1 1 100.0000
2 2 100.0000
3 3 129.3819
4 4 137.7009
5 5 187.6759
6 6 155.0566
7 7 155.0566
8 8 125.9839
9 9 159.3502
10 10 129.0750

R: Extract single month data from a monthly time-series

Question
I have a monthly time series (object axts in the code below) for the period Jan 1993 - Dec 2019 and I would like to create a time series that contains all the data for a single month, e.g. february.
Details
This is its structure:
str(axts)
An ‘xts’ object on Jan 1993/Dec 2019 containing:
Data: num [1:324, 1] -28.3 -22.8 -67.1 -122.5 -72.7 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr "SSH"
Indexed by objects of class: [yearmon] TZ: UTC
xts Attributes:
NULL
Here is its creation:
axts<-structure(c(-28.3, -22.8, -67.1, -122.5, -72.7, -102.6, 49.3, 107.2,
62.6, 98.8, 51.6, -12.8, -36.5, -22.6, -53.6, -16.3, -83.6,
-127.5, -40.2, -80.8, -71.4, -89.6, -78, -24.6, -41.8, -79.2,
-88.9, -111.3, -127.6, -97.6, -41.6, -6.3, -8, -15.8, -21.6,
1.5, 33.4, 71.5, 36, -18.8, 78.5, -20.4, 111.1, 93.5, 142.5,
110.4, 60, 78.6, 72.6, -5.2, -65.7, -102.1, -61, 109.8, 69.8,
67.7, 47.6, 64.7, 52.7, -20, -58, 41.7, 5.8, -3.1, 120.1, 180.3,
149.4, 213.7, 166.4, 78.5, 65.6, 12.1, -2.7, -46.1, -27.2,
72.8, 11.3, 46.4, 50.3, 40, 78.5, 154.8, 178.1, 99.9, 66.5,
-47.1, -76.7, -6.9, -23.6, 113.7, 37.6, 120.6, 136.9, 116.1,
79.6, 33.3, 66.8, -5.3, 8.3, 95, 81.7, 82.9, 118.6, 140, 139.8,
126.2, 157.6, 95.1, 95.7, 26.8, 116.6, 77.3, 106.7, -53.3, -104.4,
-88.1, -58.9, -17.8, 159.1, 179.8, 27.1, -88.5, -84.2, -34.3, 61,
102, 133.1, 162, 130, 124.8, 133.7, 109.6, 21.9, 123, 113.5, 102.4,
117.2, 24.9, 45.6, 71.2, 163.8, 118, 54.2, 87.4, 97.9, 127.2, 11.6,
-84.1, 15.1, 5.9, 71, 140.6, 47.4, 26.4, 36.2, 5.4, -5.4, -46.8, -25.3,
-79.4, -45.8, 40.1, -52.8, -95.5, -56.5, 175.6, 140.6, -10.5, -77.7, -26.8,
73.6, 13.4, 15.4, 128.1, 129.2, 50.6, 7.5, -27.6, 19.2, 61, 84.3, -31.2,
-19.1, 31.8, 22.4, -31, -93.9, -25.8, -4.1, 87.3, -12.8, -125.8, -58.1,
74.5, 41, -141.6, -142.1, -92.9, 25.6, 50.8, 139.3, 126.1, -10.4, 45.1,
92.2, 47.4, -1.6, -46.9, 69.4, -52.3, 18.2, 194.8, 157.6, 37.3, 28.3, -18,
-46.8, -95.8, -146, -172.4, -14.7, -33.4, -46.4, 5.9, 146.3, 124.5, 82.8,
-5.9, -124.7, -108.4, -66.3, -61.8, -62.6, 29.6, 38.5, 8.3, 158.4, 80.2, 10.5,
27.1, 21.2, 21.2, 121.8, 94.3, -86.3, -49.4, 178.4, 100.3, 68.6, 106.5, 72.1, 58.6,
-42.5, -74.6, -85.3, -100.1, -122.5, -125.7, -109.3, -100.6, -17, 2.8, -58, -32.4,
-63.2, 28.4, -99.8, -198.3, -103, 36.3, 47.5, 85.4, 124.9, 61.6, -150.2, -174.6,
-182.3, -69.3, -48.8, -10.3, 82.3, 13.9, -40, 64.1, 126.1, 15.5, 49.8, 12.3, -105,
-23.9, -51.7, -25.6, -140.1, -73.1, -66.1, -57, -20.1, -50.1, 25.3, -67.9, -47.8,
6.3, 13.2, 48.1, -50.8, 26.5, -58.4, -70.6, 81.2, 41.9, -32.6, 25.1, 118.7, 82.6,
62.6, 13.9, -149.5, 8, -32.8, 70.8, 96.9, 146.7, 106.2, -21.3),
.Dim = c(324L, 1L), index = structure(c(725846400, 728524800, 730944000, 733622400, 736214400,
738892800, 741484800, 744163200, 746841600, 749433600,
752112000, 754704000, 757382400, 760060800, 762480000,
765158400, 767750400, 770428800, 773020800, 775699200,
778377600, 780969600, 783648000, 786240000, 788918400, 791596800,
794016000, 796694400, 799286400, 801964800, 804556800, 807235200,
809913600, 812505600, 815184000, 817776000, 820454400, 823132800,
825638400, 828316800, 830908800, 833587200, 836179200, 838857600,
841536000, 844128000, 846806400, 849398400, 852076800, 854755200,
857174400, 859852800, 862444800, 865123200, 867715200, 870393600,
873072000, 875664000, 878342400, 880934400, 883612800, 886291200,
888710400, 891388800, 893980800, 896659200, 899251200, 901929600,
904608000, 907200000, 909878400, 912470400, 915148800, 917827200,
920246400, 922924800, 925516800, 928195200, 930787200, 933465600,
936144000, 938736000, 941414400, 944006400, 946684800, 949363200,
951868800, 954547200, 957139200, 959817600, 962409600, 965088000,
967766400, 970358400, 973036800, 975628800, 978307200, 980985600,
983404800, 986083200, 988675200, 991353600, 993945600, 996624000,
999302400, 1001894400, 1004572800, 1007164800, 1009843200, 1012521600,
1014940800, 1017619200, 1020211200, 1022889600, 1025481600, 1028160000,
1030838400, 1033430400, 1036108800, 1038700800, 1041379200, 1044057600,
1046476800, 1049155200, 1051747200, 1054425600, 1057017600, 1059696000,
1062374400, 1064966400, 1067644800, 1070236800, 1072915200, 1075593600,
1078099200, 1080777600, 1083369600, 1086048000, 1088640000, 1091318400,
1093996800, 1096588800, 1099267200, 1101859200, 1104537600, 1107216000,
1109635200, 1112313600, 1114905600, 1117584000, 1120176000, 1122854400,
1125532800, 1128124800, 1130803200, 1133395200, 1136073600, 1138752000,
1141171200, 1143849600, 1146441600, 1149120000, 1151712000, 1154390400,
1157068800, 1159660800, 1162339200, 1164931200, 1167609600, 1170288000,
1172707200, 1175385600, 1177977600, 1180656000, 1183248000, 1185926400,
1188604800, 1191196800, 1193875200, 1196467200, 1199145600, 1201824000,
1204329600, 1207008000, 1209600000, 1212278400, 1214870400, 1217548800,
1220227200, 1222819200, 1225497600, 1228089600, 1230768000, 1233446400,
1235865600, 1238544000, 1241136000, 1243814400, 1246406400, 1249084800,
1251763200, 1254355200, 1257033600, 1259625600, 1262304000, 1264982400,
1267401600, 1270080000, 1272672000, 1275350400, 1277942400, 1280620800,
1283299200, 1285891200, 1288569600, 1291161600, 1293840000, 1296518400,
1298937600, 1301616000, 1304208000, 1306886400, 1309478400, 1312156800,
1314835200, 1317427200, 1320105600, 1322697600, 1325376000, 1328054400,
1330560000, 1333238400, 1335830400, 1338508800, 1341100800, 1343779200,
1346457600, 1349049600, 1351728000, 1354320000, 1356998400, 1359676800,
1362096000, 1364774400, 1367366400, 1370044800, 1372636800, 1375315200,
1377993600, 1380585600, 1383264000, 1385856000, 1388534400, 1391212800,
1393632000, 1396310400, 1398902400, 1401580800, 1404172800, 1406851200,
1409529600, 1412121600, 1414800000, 1417392000, 1420070400, 1422748800,
1425168000, 1427846400, 1430438400, 1433116800, 1435708800, 1438387200,
1441065600, 1443657600, 1446336000, 1448928000, 1451606400, 1454284800,
1456790400, 1459468800, 1462060800, 1464739200, 1467331200, 1470009600,
1472688000, 1475280000, 1477958400, 1480550400, 1483228800, 1485907200,
1488326400, 1491004800, 1493596800, 1496275200, 1498867200, 1501545600,
1504224000, 1506816000, 1509494400, 1512086400, 1514764800, 1517443200,
1519862400, 1522540800, 1525132800, 1527811200, 1530403200, 1533081600,
1535760000, 1538352000, 1541030400, 1543622400, 1546300800, 1548979200,
1551398400, 1554076800, 1556668800, 1559347200, 1561939200, 1564617600,
1567296000, 1569888000, 1572566400, 1575158400),
tzone = "UTC", tclass = "yearmon", tformat = "%m/%Y"), class = c("xts", "zoo"), .Dimnames = list(NULL, "SSH"))
Because the index of axts is of yearmon class we can use cycle to get the month number so for February (2nd month of the year):
axts[cycle(axts) == 2]
giving:
SSH
02/1993 -22.8
02/1994 -22.6
02/1995 -79.2
02/1996 71.5
02/1997 -5.2
02/1998 41.7
## ...snip...
If the reason you want this is to create a plot for each month then we don't even need that as it can be done simply using monthplot which produces 12 side by side plots, one for each month.
monthplot(as.ts(axts), ylab = "SSH")
I edited your dput because there were some minor errors in it but should be good now.
I done some transformations of your data so that it is only taking the value from on specific month of each year; in this case, February.
#do some transformations first
axts_df<-as.data.frame(axts)
library(data.table)
library(lubridate)
axts_df<-setDT(axts_df, keep.rownames = T)[]
axts_df$MonthYear<-my(axts_df$rn)
axts_df$Month<-month(axts_df$MonthYear)
#for February only:-
library(dplyr)
axts_df_feb<-axts_df%>%
filter(Month==2)
#convert back into time series
axts_df_feb$rn<-NULL
axts_df_feb$Month<-NULL
axts_df_feb_ts<-ts(axts_df_feb$SSH)
plot(axts_df_feb_ts)
The plot below gives you the value for every February of each year.
However, there is a way to do this in ggplot2, you could do it like this:-
ggplot(axts_df_feb, aes(x=MonthYear,y=SSH))+geom_line()+ggtitle("Values for every February (1993-2019)")

How in R using ggplot plot first days of the week on x axis

I have the following data:
structure(list(Date = structure(c(1594166400, 1594080000, 1593993600,
1593734400, 1593648000, 1593561600, 1593475200, 1593388800, 1593129600,
1593043200, 1592956800, 1592870400, 1592784000, 1592524800, 1592438400,
1592352000, 1592265600, 1592179200, 1591920000, 1591833600, 1591747200,
1591660800, 1591574400, 1591315200, 1591228800, 1591142400, 1591056000,
1590969600, 1590710400, 1590624000, 1590537600, 1590451200, 1590364800,
1590105600, 1590019200, 1589932800, 1589846400, 1589760000, 1589500800,
1589414400, 1589328000, 1589241600, 1589155200, 1588896000, 1588809600,
1588723200, 1588636800, 1588550400, 1588291200, 1588204800, 1588118400,
1588032000, 1587945600, 1587686400, 1587600000, 1587513600, 1587427200,
1587340800, 1587081600, 1586995200, 1586908800, 1586822400, 1586736000,
1586390400, 1586304000, 1586217600, 1586131200, 1585872000, 1585785600,
1585699200, 1585612800, 1585526400, 1585267200, 1585180800, 1585094400,
1585008000, 1584921600, 1584662400, 1584576000, 1584489600, 1584403200,
1584316800, 1584057600, 1583971200, 1583884800, 1583798400, 1583712000,
1583452800, 1583366400, 1583280000, 1583193600, 1583107200, 1582848000,
1582761600, 1582675200, 1582588800, 1582502400, 1582243200, 1582156800,
1582070400, 1581984000, 1581897600, 1581638400, 1581552000, 1581465600,
1581379200, 1581292800, 1581033600, 1580947200, 1580860800, 1580774400,
1580688000, 1580428800, 1580342400, 1580256000, 1580169600, 1580083200,
1579824000, 1579737600, 1579651200, 1579564800, 1579478400, 1579219200,
1579132800, 1579046400, 1578960000, 1578873600, 1578614400, 1578528000,
1578441600, 1578355200, 1578268800), tzone = "UTC", class = c("POSIXct",
"POSIXt")), Price = c(43.24, 43.08, 43.1, 42.8, 43.14, 42.03,
41.15, 41.71, 41.02, 41.05, 40.31, 42.63, 43.08, 42.19, 41.51,
40.71, 40.96, 39.72, 38.73, 38.55, 41.73, 41.18, 40.8, 42.3,
39.99, 39.79, 39.57, 38.32, 35.33, 35.29, 34.74, 36.17, 35.53,
35.13, 36.06, 35.75, 34.65, 34.81, 32.5, 31.13, 29.19, 29.98,
29.63, 30.97, 29.46, 29.72, 30.97, 27.2, 26.44, 25.27, 22.54,
20.46, 19.99, 21.44, 21.33, 20.37, 19.33, 25.57, 28.08, 27.82,
27.69, 29.6, 31.74, 31.48, 32.84, 31.87, 33.05, 34.11, 29.94,
24.74, 22.74, 22.76, 24.93, 26.34, 27.39, 27.15, 27.03, 26.98,
28.47, 24.88, 28.73, 30.05, 33.85, 33.22, 35.79, 37.22, 34.36,
45.27, 49.99, 51.13, 51.86, 51.9, 50.52, 52.18, 53.43, 54.95,
56.3, 58.5, 59.31, 59.12, 57.75, 57.67, 57.32, 56.34, 55.79,
54.01, 53.27, 54.47, 54.93, 55.28, 53.96, 54.45, 58.16, 58.29,
59.81, 59.51, 59.32, 60.69, 62.04, 63.21, 64.59, 65.2, 64.85,
64.62, 64, 64.49, 64.2, 64.98, 65.37, 65.44, 68.27, 68.91)), row.names = c(NA,
-132L), class = c("tbl_df", "tbl", "data.frame"))
When I use code below to plot a graph y-axis has only names of the months (in total 3 names). However, I want that on the y-axis only the first days of the week are depicted like "06-01-2020", "13-01-2020"...
How can I fix it?
ggplot(Crude_oil, aes(x=Date, group=Group, color=Group)) +
geom_line(aes(y = Price), size = 2)
Doesn't need to be so complicated. No need to define the labels first. Just set the limits and use date_breaks.
# mydat <- your structure
ggplot(mydat, aes(x=lubridate::ymd(Date))) + # x needs to be date
geom_line(aes(y = Price), size = 2) +
scale_x_date(limits = c(as.Date("2020-01-06"),NA), date_breaks = "weeks") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
You need to specify the labels. It is straightforward to create a vector of labels with some help from package lubridate:
all_dates <- seq(as.POSIXct("2020-01-01"), lubridate::now(), "1 day")
Mondays <- all_dates[lubridate::wday(all_dates) == 2]
Now we can plot using the labels parameter in scale_x_datetime:
ggplot(Crude_oil, aes(x=Date)) +
geom_line(aes(y = Price), size = 2) +
scale_x_datetime(breaks = Mondays, labels = as.Date(Mondays)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

Why does my kernel density estimation on the sphere not work?

As said, I am looking for a density / probability estimation. See here for the difference to heat maps and I checked that sum(kde$fhat)*diff(kde$x1[1:2])*diff(kde$x2[1:2]) = 1 (you can run it with the example, all diffs are almost equal).
I would expect a qualitatively similar plot to this Python example (you have to scroll down a bit...),
but I get
Increasing gridsize improved the situation but faces its limits (see limit.memory()), the bandwidth slightly changes the picture, but the main feature (low density over a larger area, no density for a huge area) still remains unresolved.
What's the mistake? The algorithm or anything else? As I have bigger data sets, I include a set with 1000 points below. Reproducible example (more or less from here):
library("leaflet")
library("KernSmooth")
gc()
memory.limit(size=16000)
kde <- KernSmooth::bkde2D(dat[ , c("longitude", "latitude")],
bandwidth=c(.0045, .0068),
# bandwidth=c(.1, .1), # does not improve...
gridsize = c(6000,6000))
CL <- contourLines(kde$x1 , kde$x2 , kde$fhat)
LEVS <- as.factor(sapply(CL, `[[`, "level"))
NLEV <- length(levels(LEVS))
pgons <- lapply(1:length(CL), function(i)
sp::Polygons(list(sp::Polygon(cbind(CL[[i]]$x, CL[[i]]$y))), ID=i))
spgons = sp::SpatialPolygons(pgons)
leaflet(spgons) %>% addTiles() %>%
addCircles(lng = dat$longitude, lat = dat$latitude,
radius = .5, opacity = .9, col = "blue") %>%
addPolygons(color = heat.colors(NLEV, NULL)[LEVS])
Edit: Useful Link with overview of available packages
Data
dat <- data.frame(latitude = c(
47.086, 47.086, 46.979, 46.968, 47.053, 47.078, 47.044, 47.054,
46.935, 47.053, 46.832, 47.047, 47.065,
46.983, 47.082, 47.194, 46.962, 47.056, 46.977, 46.977, 47.171,
47.075, 47.056, 47.17, 47.043, 47.119, 47.166, 47.053, 46.771,
47.166, 47.064, 47.082, 47.144, 47.034, 47.065, 47.015, 47.032,
47.166, 47.085, 47.046, 47.209, 46.824, 47.058, 47.088, 47.083,
47.054, 47.05, 47.079, 47.046, 46.957, 47.131, 47.062, 46.962,
46.958, 47.218, 47.019, 47.042, 47.209, 47.049, 47.119, 47.041,
46.901, 46.736, 47.235, 47.05, 47.052, 47.047, 47.058, 47.135,
47.044, 47.166, 47.181, 46.88, 47.058, 47.048, 47.035, 47.058,
47.059, 46.881, 46.89, 47.065, 47.087, 47.077, 47.229, 47.082,
46.89, 47.054, 47.142, 47.048, 47.047, 47.062, 47.058, 47.026,
47.037, 47.038, 46.883, 47.059, 47.081, 47.051, 47.058, 47.249,
47.028, 47.217, 47.06, 47.05, 47.047, 47.038, 47.046, 46.962,
47.175, 47.057, 47.065, 46.821, 47.22, 46.945, 47.047, 47.151,
47.051, 47.21, 47.194, 47.171, 46.954, 46.958, 47.148, 46.818,
46.88, 46.872, 47.089, 47.037, 47.142, 47.096, 47.14, 46.969,
47.047, 47.085, 47.051, 47.13, 47.063, 47.06, 47.101, 47.05,
46.987, 47.082, 47.05, 46.89, 47.053, 47.056, 47.122, 47.041,
46.887, 47.055, 47.056, 47.042, 47.059, 46.987, 47.124, 47.062,
47.131, 47.059, 47.047, 47.055, 47.04, 47.075, 47.047, 46.959,
47.059, 47.049, 47.206, 46.9, 47.123, 47.015, 47.219, 47.166,
47.027, 47.021, 47.06, 47.153, 47.047, 47.057, 47.029, 47.042,
47.074, 47.214, 47.112, 47.086, 47.223, 47.018, 47.081, 47.173,
47.098, 46.961, 47.055, 46.973, 46.989, 47.018, 47.046, 46.944,
46.873, 47.056, 47.047, 47.223, 47.051, 47.073, 47.119, 46.962,
46.963, 47.057, 47.166, 47.047, 47.065, 47.167, 47.058, 46.87,
47.088, 47.051, 47.154, 47.035, 47.049, 46.714, 47.229, 47.09,
47.124, 47.059, 47.038, 47.038, 47.367, 46.975, 47.057, 46.833,
47.05, 47.04, 46.89, 47.139, 47.053, 47.051, 47.088, 47.051,
47.022, 46.878, 46.983, 47.075, 47.05, 47.194, 47.047, 47.188,
47.166, 47.006, 46.962, 47.062, 47.125, 46.881, 47.126, 46.957,
47.034, 47.073, 47.029, 47.075, 47.015, 47.042, 47.168, 47.096,
47.047, 47.073, 47.053, 47.047, 46.962, 46.89, 47.033, 47.033,
47.062, 46.707, 47.083, 47.051, 47.172, 47.059, 47.113, 47.032,
47.088, 47.062, 47.062, 46.89, 47.103, 47.043, 47.166, 47.058,
47.14, 47.073, 47.082, 47.153, 46.962, 47.059, 47.166, 47.059,
47.069, 47.227, 46.89, 47.232, 47.13, 47.021, 46.9, 47.085, 47.058,
47.09, 47.07, 46.906, 47.223, 46.894, 46.91, 47.08, 47.058, 47.242,
46.84, 46.89, 47.128, 47.182, 47.093, 47.05, 47.033, 47.107,
47.111, 47.166, 47.04, 47.166, 47.058, 46.89, 47.059, 47.058,
47.044, 47.059, 47.058, 46.956, 47.044, 47.152, 47.136, 47.166,
47.15, 47.052, 46.968, 47.232, 46.862, 47.034, 47.051, 47.089,
47.17, 47.084, 47.225, 47.167, 47.042, 47.078, 47.062, 47.086,
47.062, 47.061, 46.96, 47.046, 47.028, 47.058, 47.075, 47.062,
46.9, 47.125, 47.032, 47.044, 46.825, 47.048, 47.033, 47.049,
46.88, 47.157, 47.139, 47.202, 47.202, 47.059, 47.08, 47.039,
47.062, 47.166, 47.042, 47.231, 47.113, 47.056, 47.047, 47.052,
47.02, 47.156, 47.207, 46.893, 47.04, 47.065, 47.087, 47.063,
47.224, 47.02, 47.112, 47.062, 47.114, 47.058, 47.168, 47.048,
47.058, 47.055, 47.166, 46.994, 47.122, 47.081, 47.101, 47.047,
46.89, 46.978, 46.957, 47.062, 47.062, 47.038, 47.238, 47.166,
46.962, 47.038, 46.89, 47.059, 47.041, 47.047, 47.069, 46.975,
47.08, 47.086, 47.056, 47.055, 47.053, 47.074, 47.034, 47.051,
47.047, 46.875, 47.111, 47.119, 47.062, 47.058, 47.025, 47.062,
47.045, 47.117, 46.887, 46.962, 47.047, 47.107, 47.106, 47.047,
47.173, 47.184, 46.905, 47.166, 47.062, 47.153, 47.02, 47.161,
47.059, 47.055, 47.059, 47.209, 47.021, 47.058, 46.89, 47.044,
47.055, 47.13, 47.016, 47.034, 47.039, 47.188, 46.869, 47.165,
46.986, 47.049, 47.058, 47.039, 47.069, 47.036, 47.043, 47.053,
46.875, 47.103, 47.098, 47.201, 47.015, 47.047, 47.22, 47.092,
47.049, 47.209, 46.9, 47.171, 47.065, 46.956, 47.2, 47.058, 46.899,
47.032, 47.032, 47.049, 46.99, 46.944, 47.068, 47.05, 47.039,
47.11, 47.085, 46.891, 47.051, 47.225, 47.167, 46.897, 47.048,
47.05, 47.166, 47.166, 47.15, 47.222, 47.101, 46.976, 47.126,
47.061, 47.09, 47.373, 47.083, 47.039, 47.197, 46.962, 46.887,
46.89, 47.097, 47.142, 47.08, 47.062, 47.044, 47.058, 47.047,
47.212, 47.047, 47.161, 47.062, 47.045, 47.042, 46.986, 47.042,
47.137, 47.048, 46.951, 47.062, 46.954, 47.065, 47.054, 47.054,
47.044, 47.068, 46.877, 47.111, 47.173, 47.075, 47.166, 47.135,
46.957, 47.076, 46.966, 46.89, 46.985, 47.053, 47.2, 47.166,
47.065, 47.147, 47.055, 47.059, 47.088, 47.073, 47.118, 47.058,
47.058, 47.058, 47.131, 47.047, 47.033, 47.094, 47.052, 47.059,
46.904, 47.056, 47.042, 47.183, 46.884, 47.086, 47.086, 47.076,
46.89, 47.062, 46.729, 47.047, 47.152, 47.031, 47.082, 47.033,
47.174, 46.962, 47.042, 47.071, 46.869, 47.09, 47.142, 47.096,
47.071, 47.044, 47.142, 47.042, 46.884, 47.167, 46.977, 47.049,
47.059, 47.047, 46.89, 47.047, 47.051, 47.033, 47.044, 47.203,
46.823, 47.087, 47.059, 47.047, 47.177, 47.048, 46.99, 47.051,
47.061, 46.987, 47.073, 47.078, 47.055, 47.094, 46.893, 47.08,
47.171, 47.049, 47.064, 46.962, 47.054, 47.055, 46.872, 47.131,
46.872, 47.154, 47.029, 47.048, 46.872, 46.872, 46.872, 46.872,
46.872, 46.866, 47.053, 47.166, 47.042, 47.061, 47.244, 47.078,
47.124, 46.978, 47.059, 47.166, 47.074, 47.059, 47.038, 47.245,
47.245, 46.972, 46.887, 47.063, 47.057, 47.165, 47.02, 47.147,
47.017, 47.06, 47.06, 46.96, 47.05, 47.021, 46.962, 47.058, 46.987,
47.164, 47.142, 46.948, 46.967, 47.036, 47.047, 47.065, 47.066,
47.172, 47.049, 46.91, 47.084, 46.968, 46.956, 47.244, 47.115,
47.075, 47.066, 47.059, 47.027, 46.88, 47.085, 47.039, 47.033,
47.062, 47.166, 47.058, 47.17, 47.048, 47.113, 47.049, 46.825,
47.055, 47.069, 47.073, 47.03, 46.89, 47.058, 46.955, 47.037,
46.878, 47.171, 47.051, 46.957, 47.209, 47.032, 47.08, 47.151,
47.155, 47.081, 47.039, 47.168, 47.05, 47.082, 46.786, 46.837,
47.165, 46.869, 47.04, 46.907, 47.011, 47.02, 47.226, 47.047,
47.058, 47.161, 46.898, 46.787, 47.032, 46.889, 46.992, 47.016,
47.047, 47.053, 47.119, 47.061, 47.132, 47.046, 47.056, 47.166,
46.875, 47.21, 47.035, 47.053, 47.047, 47.131, 47.166, 47.042,
46.819, 47.07, 47.062, 47.08, 47.212, 47.049, 47.037, 47.08,
47.011, 46.89, 47.085, 47.092, 47.272, 47.035, 47.232, 47.035,
47.171, 47.067, 46.951, 47.086, 47.138, 47.165, 47.047, 46.882,
46.994, 46.89, 47.053, 47.166, 47.095, 47.051, 47.166, 47.047,
47.021, 47.236, 47.043, 47.187, 47.166, 47.062, 47.026, 46.862,
47.044, 47.044, 47.085, 47.053, 47.062, 46.89, 46.962, 47.166,
47.047, 47.059, 46.962, 47.074, 47.106, 47.051, 47.167, 46.966,
47.056, 47.062, 47.062, 47.062, 46.9, 47.047, 47.053, 47.077,
47.055, 47.037, 47.066, 47.042, 47.156, 47.037, 47.078, 47.13,
47.092, 46.984, 46.862, 47.093, 47.209, 47.204, 47.122, 47.051,
47.038, 47.142, 47.135, 47.129, 47.152, 47.083, 47.044, 47.053,
47.177, 47.062, 47.047, 46.944, 47.055, 47.199, 47.079, 47.036,
47.044, 47.051, 46.962, 47.079, 47.021, 46.962, 46.962, 46.897,
47.122, 47.165, 47.058, 47.055, 47.084, 47.069, 47.058, 46.91,
47.058, 47.034, 47.172, 47.065, 47.032, 47.033, 47.049, 46.704,
47.153, 47.147, 47.057, 47.035, 46.884, 47.051, 47.059, 47.151,
47.032, 47.087, 46.962, 47.014, 46.962, 47.036, 47.058, 46.963,
47.075, 46.865, 47.171, 47.064, 46.828, 47.047, 47.076, 47.059,
47.042, 47.06, 47.029, 47.166, 47.101, 47.105, 47.074, 46.962,
47.161, 47.058, 47.142, 46.979, 46.926, 47.05, 47.141, 47.058,
47.058, 47.075, 47.062, 47.176, 47.065, 47.059, 46.979, 47.095,
46.962, 47.237, 47.05, 47.012, 47.023, 47.033, 47.062, 47.122,
47.168, 47.063, 47.061, 46.859, 46.889, 47.029, 47.065, 47.039,
46.962, 47.032, 47.044, 46.866, 46.89, 47.209, 47.18, 46.857,
47.031, 47.021, 46.991, 47.048, 46.962, 46.884, 46.895, 46.884,
47.165, 46.957, 46.962, 47.047, 47.08, 47.08, 46.952, 47.115,
47.059, 46.874, 47.05, 47.211, 47.214, 47.183, 46.965, 47.075,
47.051, 46.861, 47.209, 47.076, 47.041, 46.881, 47.024),
longitude = c(8.262, 8.435, 8.337, 8.364, 8.301, 8.361, 8.297, 8.337, 8.394, 8.283,
8.289, 8.307, 8.078, 8.41, 8.344, 8.521, 8.356, 8.312, 8.306,
8.306, 8.104, 8.438, 8.098, 8.29, 8.373, 8.342, 8.118, 8.3, 8.671,
8.118, 8.278, 8.13, 8.014, 8.332, 8.318, 8.478, 8.284, 8.118,
8.351, 8.302, 8.192, 8.65, 8.294, 8.319, 8.444, 8.069, 8.311,
8.299, 8.302, 8.371, 8.192, 8.299, 8.356, 8.369, 7.95, 8.311,
8.185, 8.187, 8.339, 7.988, 8.324, 8.281, 8.628, 8.078, 8.314,
8.294, 8.314, 8.326, 8.192, 8.297, 8.118, 8.283, 8.016, 8.294,
8.376, 8.244, 8.294, 8.348, 8.645, 8.244, 8.078, 8.34, 8.277,
7.844, 8.344, 8.244, 8.385, 8.132, 8.309, 8.314, 8.299, 8.294,
8.307, 8.155, 8.288, 8.646, 8.294, 8.44, 8.311, 8.284, 7.97,
8.305, 8.267, 8.285, 8.309, 8.298, 8.261, 8.38, 8.356, 8.128,
8.289, 8.073, 8.653, 8.158, 7.424, 8.314, 8.318, 8.339, 8.097,
8.515, 8.104, 8.047, 8.39, 8.223, 8.411, 8.244, 8.376, 8.278,
8.281, 7.973, 8.279, 7.924, 8.352, 8.314, 8.351, 8.262, 8.319,
8.319, 8.275, 8.28, 8.275, 8.311, 8.304, 8.311, 8.244, 8.259,
8.32, 7.99, 8.298, 8.231, 8.356, 8.292, 8.318, 8.279, 8.311,
8.349, 8.299, 8.315, 8.294, 8.302, 8.332, 8.323, 8.279, 8.314,
8.36, 8.279, 8.299, 8.194, 8.269, 8.397, 8.31, 8.262, 8.118,
8.279, 8.316, 8.276, 8.163, 8.314, 8.324, 8.421, 8.311, 8.36,
7.989, 8.096, 8.397, 8.113, 8.316, 8.441, 7.989, 8.267, 8.363,
8.282, 8.338, 8.313, 8.311, 8.309, 8.277, 8.271, 8.313, 8.314,
8.253, 8.311, 8.274, 7.991, 8.356, 8.37, 8.331, 8.118, 8.314,
8.078, 8.289, 8.294, 8.655, 8.272, 8.306, 8.324, 8.292, 8.299,
8.612, 8.262, 8.267, 8.352, 8.285, 8.425, 8.312, 8.499, 8.427,
8.302, 8.184, 8.256, 8.309, 8.244, 8.194, 8.267, 8.311, 7.959,
8.308, 8.312, 8.713, 8.403, 8.29, 8.301, 8.515, 8.314, 8.017,
8.118, 8.305, 8.356, 8.28, 8.386, 8.253, 8.199, 8.371, 8.423,
8.288, 8.335, 8.329, 8.48, 8.326, 8.106, 8.454, 8.264, 8.275,
8.35, 8.314, 8.356, 8.244, 8.286, 8.284, 8.299, 8.597, 8.344,
8.337, 8.283, 8.294, 8.393, 8.279, 8.354, 8.299, 8.299, 8.244,
8.342, 8.362, 8.118, 8.294, 8.192, 8.26, 8.312, 8.168, 8.356,
8.29, 8.118, 8.428, 8.316, 8.078, 8.244, 8.08, 8.138, 8.316,
8.275, 8.351, 8.294, 8.267, 8.325, 7.93, 8.11, 8.249, 8.622,
8.44, 8.326, 8.226, 8.175, 8.244, 8.236, 7.982, 7.97, 8.307,
8.272, 8.194, 8.195, 8.118, 8.319, 8.118, 8.294, 8.244, 8.279,
8.294, 8.297, 8.279, 8.294, 8.382, 8.297, 8.089, 8.317, 8.118,
8.172, 8.284, 8.364, 8.078, 8.644, 8.27, 8.309, 8.278, 8.115,
8.041, 8.081, 8.295, 8.366, 8.333, 8.299, 8.294, 8.315, 8.388,
8.528, 8.305, 8.294, 8.294, 8.286, 8.299, 8.274, 8.446, 8.279,
8.297, 8.651, 8.313, 8.329, 8.313, 8.646, 8.116, 7.919, 8.234,
8.234, 8.294, 8.345, 8.303, 8.312, 8.118, 8.187, 8.237, 8.096,
7.949, 8.302, 8.3, 8.315, 8.316, 8.189, 8.245, 8.307, 8.078,
8.289, 8.073, 8.26, 8.311, 8.454, 8.299, 8.277, 8.294, 8.098,
8.309, 8.308, 8.321, 8.118, 8.308, 8.355, 8.348, 8.253, 8.314,
8.249, 8.341, 8.369, 8.299, 8.299, 8.181, 8.139, 8.118, 8.356,
8.327, 8.249, 8.294, 8.298, 8.314, 8.317, 8.343, 8.345, 8.039,
8.35, 8.299, 8.307, 8.366, 8.266, 8.296, 8.315, 8.641, 8.195,
7.988, 8.299, 8.326, 8.307, 8.315, 8.303, 7.984, 8.231, 8.356,
8.314, 8.451, 8.355, 8.068, 8.1, 8.027, 8.274, 8.118, 8.074,
8.325, 8.278, 8.104, 8.301, 8.318, 8.294, 8.196, 8.308, 8.315,
8.244, 8.306, 8.318, 8.319, 8.301, 8.143, 8.179, 7.975, 8.643,
8.114, 8.312, 8.306, 8.302, 8.289, 8.36, 8.321, 8.304, 8.302,
8.664, 8.267, 8.465, 8.247, 8.309, 8.305, 8.249, 8.395, 8.268,
8.178, 8.269, 8.285, 8.078, 8.273, 8.314, 8.294, 8.262, 8.278,
8.285, 8.312, 8.424, 8.277, 8.366, 8.309, 8.325, 8.361, 8.437,
8.239, 8.308, 8.147, 8.291, 8.391, 8.301, 8.312, 8.118, 8.118,
8.229, 8.264, 8.269, 8.344, 8.402, 8.353, 8.105, 8.559, 8.337,
8.32, 8.229, 8.356, 8.231, 8.244, 8.276, 8.132, 8.287, 8.299,
8.297, 8.294, 8.264, 8.016, 8.314, 8.296, 8.299, 8.28, 8.301,
8.412, 8.301, 8.315, 8.364, 8.383, 8.299, 8.014, 8.078, 8.346,
8.346, 8.314, 8.317, 8.643, 8.321, 8.1, 8.27, 8.118, 8.131, 8.336,
8.286, 8.47, 8.244, 8.312, 8.345, 8.314, 8.118, 8.078, 8.016,
8.311, 8.294, 8.292, 8.295, 7.987, 8.294, 8.294, 8.294, 8.315,
8.314, 8.327, 8.344, 8.294, 8.294, 8.277, 8.349, 8.14, 8.006,
8.637, 8.346, 8.03, 8.267, 8.244, 8.299, 8.546, 8.289, 8.167,
8.278, 7.954, 8.286, 8.103, 8.356, 8.301, 8.288, 8.652, 8.267,
8.132, 8.369, 8.282, 8.297, 8.132, 8.315, 8.637, 8.291, 8.417,
8.262, 8.279, 8.314, 8.244, 8.314, 8.311, 8.293, 8.3, 8.432,
8.404, 8.289, 8.294, 8.298, 8.101, 8.267, 8.306, 8.311, 8.306,
8.311, 8.434, 8.343, 8.324, 8.372, 8.245, 8.301, 8.113, 8.262,
8.306, 8.356, 8.311, 8.304, 8.376, 8.192, 8.376, 8.03, 8.421,
8.348, 8.376, 8.376, 8.376, 8.376, 8.376, 8.65, 8.338, 8.118,
8.324, 8.281, 8.137, 8.343, 8.163, 8.415, 8.294, 8.118, 8.329,
8.294, 8.321, 8.223, 8.223, 8.444, 8.231, 8.303, 8.301, 8.29,
8.307, 8.234, 8.31, 8.068, 8.347, 8.362, 8.307, 8.316, 8.356,
8.294, 8.415, 8.298, 8.132, 8.05, 8.422, 8.329, 8.314, 8.078,
8.017, 8.096, 8.309, 7.936, 8.31, 8.364, 8.365, 7.966, 7.993,
8.283, 8.077, 8.294, 8.302, 8.244, 8.434, 8.313, 8.286, 8.286,
8.118, 8.294, 8.105, 8.376, 8.393, 8.313, 8.391, 8.346, 8.316,
8.275, 8.25, 8.244, 8.326, 8.362, 8.311, 8.647, 8.106, 8.308,
8.37, 8.196, 8.284, 8.084, 8.167, 8.214, 8.277, 8.185, 8.142,
8.264, 8.444, 8.162, 8.634, 8.291, 8.644, 8.182, 8.297, 8.339,
8.315, 8.255, 8.314, 8.326, 8.291, 8.248, 8.159, 8.284, 8.206,
8.305, 8.661, 8.302, 8.069, 7.992, 8.31, 8.195, 8.191, 8.344,
8.118, 8.664, 7.979, 8.281, 8.286, 8.302, 8.195, 8.118, 8.326,
8.387, 8.325, 8.299, 8.281, 8.093, 8.303, 8.272, 8.281, 8.293,
8.249, 8.349, 8.342, 8.235, 8.259, 8.08, 8.259, 8.293, 8.314,
8.62, 8.442, 8.083, 8.297, 8.264, 8.247, 8.308, 8.244, 8.3, 8.118,
8.278, 8.298, 8.118, 8.29, 8.316, 8.077, 8.313, 8.237, 8.118,
8.299, 8.307, 8.644, 8.35, 8.297, 8.351, 8.284, 8.299, 8.244,
8.356, 8.118, 8.298, 8.294, 8.356, 8.335, 8.374, 8.27, 8.118,
8.382, 8.301, 8.299, 8.299, 8.299, 8.626, 8.298, 8.285, 8.277,
8.324, 8.282, 8.314, 8.301, 8.328, 8.183, 8.264, 8.311, 8.35,
8.413, 8.644, 8.275, 8.093, 8.039, 7.99, 8.347, 8.306, 8.132,
7.924, 8.319, 8.115, 8.125, 8.297, 8.277, 8.209, 8.299, 8.314,
8.277, 8.308, 7.967, 8.124, 8.431, 8.314, 8.311, 8.356, 8.27,
8.316, 8.356, 8.356, 8.26, 7.987, 8.297, 8.294, 8.316, 8.345,
8.281, 8.088, 8.622, 8.294, 8.27, 8.096, 8.078, 8.284, 8.449,
8.301, 8.6, 8.325, 8.108, 8.341, 8.328, 8.637, 8.298, 8.294,
8.227, 8.442, 8.037, 8.356, 8.305, 8.356, 8.333, 8.326, 8.363,
8.283, 8.649, 8.102, 8.316, 8.188, 8.314, 8.267, 8.279, 8.318,
8.347, 8.056, 8.118, 8.203, 8.269, 8.338, 8.356, 8.265, 8.326,
8.132, 8.341, 8.26, 8.339, 8.327, 8.294, 8.294, 8.438, 8.315,
8.136, 8.078, 8.294, 8.419, 8.27, 8.016, 8.073, 8.34, 8.486,
8.307, 8.275, 8.315, 7.99, 7.996, 8.303, 8.275, 8.655, 8.249,
8.421, 8.078, 8.314, 8.356, 8.289, 8.297, 8.237, 8.244, 8.178,
8.112, 8.646, 8.399, 8.316, 8.307, 8.301, 8.356, 8.637, 8.621,
8.637, 8.297, 8.372, 8.356, 8.314, 8.441, 8.345, 8.016, 8.39,
8.279, 8.674, 8.312, 7.99, 7.991, 8.023, 8.475, 8.283, 8.308,
8.658, 8.096, 8.439, 8.306, 8.645, 8.454),
stringsAsFactors = FALSE)
You may want to look at leaflet.extras. It has inbuilt heat map opportunities.
library(magrittr)
library(leaflet)
library(leaflet.extras)
leaflet(dat) %>% addTiles() %>%
addHeatmap(lng = ~longitude, lat = ~latitude, radius = 10, minOpacity = .5) %>%
addCircles(lng = ~longitude, lat = ~latitude)
To further fit it to your needs you may want to play with radius, blur, minOpacity and max attributes. To adjust the color palette you can use gradient.
For example:
leaflet(dat) %>% addTiles() %>%
addHeatmap(lng = ~longitude, lat = ~latitude, blur = 20, radius = 10, minOpacity = .5, gradient = RColorBrewer::brewer.pal(7, "Reds")) %>%
addCircles(lng = ~longitude, lat = ~latitude)

Construct multiple series ("mts") in R

I cannot find working example how to make mts object for time-series.
I have made an example of input data. There is one timeseries structured with frequency 4. I would like to separate it to 4 timeseries represented as mts format (described in documentation for ts):
class
class to be given to the result, or none if NULL or "none". The default is "ts" for a single series, c("mts", "ts", "matrix") for multiple series.
How I can split it? I couldn't find any documentation of examples how "mts" objects can be created.
Qtr1 Qtr2 Qtr3 Qtr4
1 100.00 102.09 102.50 102.60
2 102.66 102.01 100.70 102.21
3 102.50 102.81 102.91 103.08
4 103.25 101.70 101.10 101.49
5 100.12 99.40 99.28 97.75
6 96.65 99.03 99.28 99.91
7 99.29 98.57 98.45 100.27
8 100.65 102.12 101.55 101.55
9 99.51 99.95 98.91 96.87
10 95.14 94.82 96.04 96.91
11 95.53 93.14 92.97 94.54
12 91.72 92.35 94.79 94.78
13 95.50 95.97 94.64 96.56
14 96.45 95.13 94.32 92.92
Appendix
structure(c(100, 102.09, 102.5, 102.6, 102.66, 102.01, 100.7,
102.21, 102.5, 102.81, 102.91, 103.08, 103.25, 101.7, 101.1,
101.49, 100.12, 99.4, 99.28, 97.75, 96.65, 99.03, 99.28, 99.91,
99.29, 98.57, 98.45, 100.27, 100.65, 102.12, 101.55, 101.55,
99.51, 99.95, 98.91, 96.87, 95.14, 94.82, 96.04, 96.91, 95.53,
93.14, 92.97, 94.54, 91.72, 92.35, 94.79, 94.78, 95.5, 95.97,
94.64, 96.56, 96.45, 95.13, 94.32, 92.92, 92.58, 89.74, 87.7,
89.5, 86.69, 87.91, 89.12, 88.93, 89.95, 90.42, 90.22, 90.75,
90.2, 89.5, 90.52, 90.88, 90.98, 91.85, 92.03, 91.85, 92.54,
92.69, 92.36, 92.35, 91.56, 92.67, 92.88, 92.26, 92.36, 92.51,
92.26, 92.47, 92.65, 92.89, 91.67, 91.95, 92.77, 92.59, 91.83,
92.2, 91.47, 92.33, 92.03, 92.74, 92.74, 93.13, 94.61, 95.23,
95.04, 95.35, 96.46, 96.6, 95.93, 95.61, 95.22, 95.34, 95.58,
95.64, 94.41, 94.73, 93.64, 92.87, 92.89, 93.67, 94.69, 94.51,
94.14, 94.53, 94.63, 95.15, 94.67, 95.75, 96.16, 96.99, 97.3,
97.97, 98.34, 98.28, 97.85, 97.54, 97.48, 97.09, 97.28, 97.8,
97.08, 96.28, 94.58, 92.94, 91.26, 91.92, 91.03, 92.13, 94.45,
94.68, 95.02, 95.79, 92.29, 89.45, 91.52, 93.9, 94.51, 95.47,
95.1, 93.4, 92.55, 93.33, 94.33, 95.8, 96.19, 96.4, 96.72, 96.34,
96.7, 96.22, 97.27, 96.84, 97.08, 97.14, 97.45, 97.65, 96.6,
96.99, 95.89, 95.62, 96.48, 97.5, 97.57, 98.43, 98.37, 99.31,
99.27, 99.38, 98.45, 97.56, 98.06, 97.39, 97.69, 98.21, 98.12,
97.56, 97.97, 98.01, 98.47, 98.14, 97.87, 99.25, 99.73, 99.55,
99.8, 99.74, 98.96, 98.12, 98.07, 98.12, 98.53, 97.87, 98.66,
98.89, 98.9, 99.94, 99.66, 98.7, 98.59, 99.22, 98.68, 98.74,
99.39, 100.06, 99.77, 99.48, 98.73, 99.41, 98.95, 98.35, 97.54,
98.64, 97.71, 98.44, 98.85, 98.31, 98.22, 97.72, 97.27, 97.31,
97.31, 97.27, 96.9, 95.1, 94.73, 94.03, 95.68, 95.94, 97.13,
97.39, 96.62, 96.93, 97.26, 97.48, 98.23, 98.1, 97.52, 96.88,
96.81, 97.39, 98.39, 97.93, 98.48, 98.64, 97.77, 97.74, 98.44,
99.1, 99.16, 99.27, 100.41, 99.54, 100.67, 100.21, 100.87, 101.45,
101.42, 101.52, 101.55, 101.7, 101.8, 102.18, 102.16, 102.05,
101.86, 102.97, 103.43, 103.75, 103.85, 103.86, 103.99, 103.87,
103.39, 104.23, 103.47, 102.98, 103.01, 102.92, 102.75, 102.24,
102.22, 103.86, 104.07, 103.72, 102.97, 102.86, 103.26, 102.72,
103.57, 103.35, 103.88, 103.86, 104.56, 104.79, 104.9, 104.66,
105.25, 105.1, 105.4, 105.61, 106.15, 106.28, 106.15, 105.53,
105.67, 105.94, 106.88, 107.58, 107.64, 107.61, 107.35, 107.41,
107.53, 107.91, 108.02, 107.77, 108.07, 108.4, 108.69, 108.71,
107.81, 107.18, 108.02, 107.87, 107.53, 107.64, 108.33, 108.87,
108.71, 108.45, 108.64, 108.7, 108.74, 108.79, 109.23, 109.42,
109.82, 109.52, 108.95, 109.26, 109.36, 109.35, 110.22, 110.72
), .Dim = c(364L, 1L), index = structure(c(1447632000, 1447718400,
1447804800, 1447891200, 1447977600, 1448236800, 1448323200, 1448409600,
1448496000, 1448582400, 1448841600, 1448928000, 1449014400, 1449100800,
1449187200, 1449446400, 1449532800, 1449619200, 1449705600, 1449792000,
1450051200, 1450137600, 1450224000, 1450310400, 1450396800, 1450656000,
1450742400, 1450828800, 1451260800, 1451347200, 1451433600, 1451520000,
1451865600, 1451952000, 1452038400, 1452124800, 1452211200, 1452470400,
1452556800, 1452643200, 1452729600, 1452816000, 1453075200, 1453161600,
1453248000, 1453334400, 1453420800, 1453680000, 1453766400, 1453852800,
1453939200, 1454025600, 1454284800, 1454371200, 1454457600, 1454544000,
1454630400, 1454889600, 1454976000, 1455062400, 1455148800, 1455235200,
1455494400, 1455580800, 1455667200, 1455753600, 1455840000, 1456099200,
1456185600, 1456272000, 1456358400, 1456444800, 1456704000, 1456790400,
1456876800, 1456963200, 1457049600, 1457308800, 1457395200, 1457481600,
1457568000, 1457654400, 1457913600, 1.458e+09, 1458086400, 1458172800,
1458259200, 1458518400, 1458604800, 1458691200, 1458777600, 1459209600,
1459296000, 1459382400, 1459468800, 1459728000, 1459814400, 1459900800,
1459987200, 1460073600, 1460332800, 1460419200, 1460505600, 1460592000,
1460678400, 1460937600, 1461024000, 1461110400, 1461196800, 1461283200,
1461542400, 1461628800, 1461715200, 1461801600, 1461888000, 1462147200,
1462233600, 1462320000, 1462492800, 1462752000, 1462838400, 1462924800,
1463011200, 1463097600, 1463443200, 1463529600, 1463616000, 1463702400,
1463961600, 1464048000, 1464134400, 1464220800, 1464307200, 1464566400,
1464652800, 1464739200, 1464825600, 1464912000, 1465171200, 1465257600,
1465344000, 1465430400, 1465516800, 1465776000, 1465862400, 1465948800,
1466035200, 1466121600, 1466380800, 1466467200, 1466553600, 1466640000,
1466726400, 1466985600, 1467072000, 1467158400, 1467244800, 1467331200,
1467590400, 1467676800, 1467763200, 1467849600, 1467936000, 1468195200,
1468281600, 1468368000, 1468454400, 1468540800, 1468800000, 1468886400,
1468972800, 1469059200, 1469145600, 1469404800, 1469491200, 1469577600,
1469664000, 1469750400, 1470096000, 1470182400, 1470268800, 1470355200,
1470614400, 1470700800, 1470787200, 1470873600, 1470960000, 1471219200,
1471305600, 1471392000, 1471478400, 1471564800, 1471824000, 1471910400,
1471996800, 1472083200, 1472169600, 1472428800, 1472515200, 1472601600,
1472688000, 1472774400, 1473033600, 1473120000, 1473206400, 1473292800,
1473379200, 1473638400, 1473724800, 1473811200, 1473897600, 1473984000,
1474243200, 1474329600, 1474416000, 1474502400, 1474588800, 1474848000,
1474934400, 1475020800, 1475107200, 1475193600, 1475452800, 1475539200,
1475625600, 1475712000, 1475798400, 1476057600, 1476144000, 1476230400,
1476316800, 1476403200, 1476662400, 1476748800, 1476835200, 1476921600,
1477008000, 1477267200, 1477353600, 1477440000, 1477526400, 1477612800,
1477872000, 1478044800, 1478131200, 1478217600, 1478476800, 1478563200,
1478649600, 1478736000, 1478822400, 1479081600, 1479168000, 1479254400,
1479340800, 1479427200, 1479686400, 1479772800, 1479859200, 1479945600,
1480032000, 1480291200, 1480377600, 1480464000, 1480550400, 1480636800,
1480896000, 1480982400, 1481068800, 1481155200, 1481241600, 1481500800,
1481587200, 1481673600, 1481760000, 1481846400, 1482105600, 1482192000,
1482278400, 1482364800, 1482451200, 1482796800, 1482883200, 1482969600,
1483056000, 1483401600, 1483488000, 1483574400, 1483660800, 1483920000,
1484006400, 1484092800, 1484179200, 1484265600, 1484524800, 1484611200,
1484697600, 1484784000, 1484870400, 1485129600, 1485216000, 1485302400,
1485388800, 1485475200, 1485734400, 1485820800, 1485907200, 1485993600,
1486080000, 1486339200, 1486425600, 1486512000, 1486598400, 1486684800,
1486944000, 1487030400, 1487116800, 1487203200, 1487289600, 1487548800,
1487635200, 1487721600, 1487808000, 1487894400, 1488153600, 1488240000,
1488326400, 1488412800, 1488499200, 1488758400, 1488844800, 1488931200,
1489017600, 1489104000, 1489363200, 1489449600, 1489536000, 1489622400,
1489708800, 1489968000, 1490054400, 1490140800, 1490227200, 1490313600,
1490572800, 1490659200, 1490745600, 1490832000, 1490918400, 1491177600,
1491264000, 1491350400, 1491436800, 1491523200, 1491782400, 1491868800,
1491955200, 1492041600, 1492473600, 1492560000, 1492646400, 1492732800,
1492992000, 1493078400), tzone = "UTC", tclass = "Date"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", .Dimnames = list(
NULL, "Series 1"), class = "ts", .Tsp = c(1, 91.75, 4))
A multiple time series example build on hourly data.
require(stats)
require(lubridate)
data_mts <- ts(data=yourDATA[,c("Qtr1","Qtr2","Qtr3","Qtr4")],
frequency=61320, start=c(year(min(data_IE$time)),month(min(data_IE$time)), date(min(data_IE$time)),hour(min(data_IE$time))))
#This frequency variable is for hourly data,hourly frequency, i.e. 61320.
Using xts and zoo packages you could create individual time series and merge them as follows:
library("xts")
library("zoo") #for as.yearqtr
#tsDF, your input data
#extract individual time series
tsMat = matrix(tsDF,ncol=4)
#setup hypothetical indices as yearqtr e.g. 1990 Q1, 1992 Q2 etc.
startYear1 = 1990
startYear2 = 1990
startYear3 = 1991
startYear4 = 1992
index1=seq(startYear1,by=1,length.out=nrow(tsMat))
index2=seq(startYear2,by=1,length.out=nrow(tsMat))
index3=seq(startYear3,by=1,length.out=nrow(tsMat))
index4=seq(startYear4,by=1,length.out=nrow(tsMat))
index1 = as.yearqtr(paste(index1,"Q1",sep=" "))
index2 = as.yearqtr(paste(index2,"Q2",sep=" "))
index3 = as.yearqtr(paste(index3,"Q3",sep=" "))
index4 = as.yearqtr(paste(index4,"Q4",sep=" "))
#combine indices in a list
listIndices = list(index1,index2,index3,index4)
nameVec = paste0("Qtr",1:4)
#Use lapply to create individual xts time series with its correponding index created above
tsList =
lapply(1:ncol(tsMat), function(x) {
xtsObj = xts(tsMat[,x],order.by=listIndices[[x]])
colnames(xtsObj) = nameVec[x]
return(xtsObj)
})
Output:
#Use Reduce function to merge the list output from previous step
tsAggregate = Reduce(function(x,y) merge.xts(x,y),tsList)
head(tsAggregate,10)
# Qtr1 Qtr2 Qtr3 Qtr4
#1990 Q1 100.00 NA NA NA
#1990 Q2 NA 91.95 NA NA
#1991 Q1 102.09 NA NA NA
#1991 Q2 NA 92.77 NA NA
#1991 Q3 NA NA 97.57 NA
#1992 Q1 102.50 NA NA NA
#1992 Q2 NA 92.59 NA NA
#1992 Q3 NA NA 98.43 NA
#1992 Q4 NA NA NA 100.21
#1993 Q1 102.60 NA NA NA

Resources