I'm trying to do a cross-correlation plot in a data frame which has multiple values on the key variable(Ship-to-party)
I'm able to get the cross correlation values for different values of the key variable using "CCF" function from feasts package.
From the correlation it clearly implies that the lead values of independent variable is correlating well with the dependent variable for all values in the Key variable(Ship-to-party).
But there is no specific function to show the lead relationship on a plot.
There is this function lag2.plot from ASTSA package which shows all lag period relationship between independent and dependent variable in a single plot.
Could someone please advise on how to do a similar plot when there is a lead relationship between independent and dependent variable?
library(tidyverse)
library(data.table)
library(tibble)
library(tibbletime)
library(lubridate)
library(tsibble)
library(ISOweek)
library(fpp3)
library(ggplot2)
Df<-structure(list(`Ship-To.Party` = c("A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100"), Shipment = c(29,
82, 33, 52, 103, 62, 82, 59, 38, 96, 58, 112, 127, 178, 86, 128,
144, 137, 116, 105, 115, 142, 142, 111, 194, 116, 42, 91, 63,
100, 109, 106, 131, 96, 47, 45, 120, 187, 142, 68, 88, 126, 56,
122, 131, 121, 99, 86, 48, 185, 88, 43, 40, 59, 63, 59, 70, 159,
56, 77, 140, 51, 209, 199, 71, 73, 61, 45, 79, 77, 55, 67, 160,
171, 149, 120, 111, 75, 27, 89, 130, 72, 49, 82, 83, 92, 69,
68, 88, 98, 91, 75, 42, 107, 107, 76, 87, 114, 76, 31, 100, 189,
172, 39, 86, 74, 132, 138, 139, 114, 64, 21, 105, 121, 104, 84,
156, 77, 70, 56, 102, 110, 94, 102, 116, 79, 47, 89, 80, 89,
45, 19, 31, 63, 60, 75, 68, 57, 25, 29, 14, 31, 47, 97, 25, 53,
52, 35, 57, 25, 74, 18, 47, 85, 45, 24, 36, 47, 33, 30, 30, 45,
42, 54, 43, 124, 356, 140, 258, 162, 236, 236, 260, 154, 390,
184, 285, 376, 186, 262, 198, 222, 284, 342, 162, 442, 296, 444,
348, 502, 386, 136, 514, 416, 628, 432, 342, 328, 264, 246, 250,
334, 294, 476, 496, 486, 374, 278, 232, 468, 676, 538, 276, 318,
466, 306, 106, 144, 422, 248, 110, 310, 222, 248, 190, 484, 188,
200, 236, 138, 154, 170, 180, 330, 486, 646, 806, 184, 192, 236,
146, 200, 208, 150, 216, 350, 238, 208, 248, 252, 464, 224, 190,
226, 400, 194, 146, 408, 336, 202, 158, 374, 292, 0, 78, 0, 0,
0, 88, 90, 30, 46, 10, 0, 22, 23, 22, 0, 57, 25, 18, 30, 5, 4,
35, 148, 101, 7, 0, 0, 76, 153, 145, 52, 84, 0, 0, 16, 22, 22,
62, 50, 40, 64, 56, 17, 62, 113, 38, 48, 38, 21, 12, 56, 67,
49, 31, 78, 56, 0, 14, 0, 0, 22, 28, 56, 20, 0, 0, 36), ADJUSTEDSALESUNITS = c(1.859804,
40.8598, 58.859792, 64.859794, 17.859795, 88.150199, 74.150197,
76.15019, 29.138793, 41.138794, 84.138788, 76.138778, 81.138793,
55.001575, 70.001579, 119.001527, 108.001575, 63.979395, 45.979375,
94.979362, 183.979346, 65.507284, 81.507282, 169.507285, 96.507226,
369.507286, 37.176916, 94.176901, 69.176901, 87.176898, 116.476211,
51.476248, 65.476249, 131.476217, 107.76062, 75.760579, 38.76058,
47.760575, 159.760589, 83.960769, 67.960764, 68.960766, 143.960764,
60.960764, 92.295107, 107.295112, 138.295111, 31.295116, 70.999239,
122.999239, 117.999226, 111.999232, 16.574806, 44.574806, 43.574795,
29.574801, 73.574804, 36.379326, 71.379319, 53.37931, 78.45366,
49.453659, 88.453659, 64.453664, 147.453661, 84.734283, 88.734272,
90.734285, 62.734288, 40.807326, 57.807318, 62.807309, 95.807283,
45.606616, 122.606616, 99.606616, 104.606616, 139.606616, 63.974414,
47.974406, 94.974406, 167.974406, 74.829931, 64.829932, 53.829933,
97.829933, 58.847724, 89.847725, 70.84772, 101.84772, 113.847707,
79.231895, 68.231863, 67.231863, 82.231863, 116.231862, 68.209064,
74.209073, 127.209063, 35.209059, 87.366177, 78.366177, 97.366177,
162.366176, 0, 108.183635, 48.183603, 51.183603, 87.183603, 98.183603,
80.040017, 2.040021, 107.039998, 56, 87, 100, 89, 123, 33, 74,
75, 117, 61, 60, 101, 135, 81, 70, 82, 159, 106, 61, 52, 61,
63, 34, 79, 50, 51, 42, 56, 37, 53, 70, 25, 35, 31, 24, 20, 39,
42, 14, 40, 53, 73, 38, 108, 28, 32, 40, 36, 22, 66, 97, 60,
38.472599, 89.473138, 132.472625, 89.473114, 107.472616, 99.364975,
69.364963, 83.364997, 102.57104, 100.571258, 131.571056, 130.571252,
179.571252, 70.402804, 83.402802, 108.402803, 155.402803, 91.325733,
109.32571, 148.325722, 103.325708, 220.101539, 147.101548, 184.101551,
219.101232, 227.101536, 155.798089, 210.798082, 188.798089, 168.798077,
229.824672, 107.824479, 226.824462, 195.824259, 157.312521, 107.311828,
149.311851, 148.311808, 233.311811, 157.474866, 178.475849, 187.475819,
253.475843, 194.474865, 206.277286, 207.277289, 224.277305, 235.277272,
219.183634, 304.183634, 342.184053, 179.184051, 40.723634, 104.723631,
188.723644, 111.723639, 74.723632, 133.014992, 137.014954, 96.014996,
113.522629, 85.522636, 99.522631, 97.522641, 123.522634, 45.073698,
36.073724, 33.073709, 60.073697, 54.477029, 44.477043, 108.477028,
99.477013, 117.088434, 159.088448, 123.088442, 210.088442, 206.08844,
181.764858, 164.764853, 187.764853, 134.764858, 114.873765, 159.87374,
151.87376, 140.873759, 204.923902, 87.923912, 122.9239, 147.923905,
246.923899, 153.136986, 147.136986, 121.136986, 177.136986, 204.136972,
141.517995, 152.517991, 189.517988, 218.517975, 136.488671, 212.488671,
188.488671, 199.488659, 0, 77.666148, 129.666148, 74.666148,
96.666148, 89.666144, 123.960513, 105.960491, 118.960463, 95,
125, 76, 149, 144, 137, 119, 128, 170, 139, 123, 124, 122, 150,
172, 215, 158, 159, 85, 127, 50, 65, 80, 62, 120, 103, 84, 71,
56, 119, 84, 93, 62, 78, 102, 52, 100, 67, 35, 103, 74, 85, 46,
28, 22, 32, 36, 34, 27, 48, 48, 54), Week.1 = structure(c(17896,
17903, 17910, 17917, 17924, 17931, 17938, 17945, 17952, 17959,
17966, 17973, 17980, 17987, 17994, 18001, 18008, 18015, 18022,
18029, 18036, 18043, 18050, 18057, 18064, 18071, 18078, 18085,
18092, 18099, 18106, 18113, 18120, 18127, 18134, 18141, 18148,
18155, 18162, 18169, 18176, 18183, 18190, 18197, 18204, 18211,
18218, 18225, 18232, 18239, 18246, 18253, 18260, 18267, 18274,
18281, 18288, 18295, 18302, 18309, 18316, 18323, 18330, 18337,
18344, 18351, 18358, 18365, 18372, 18379, 18386, 18393, 18400,
18407, 18414, 18421, 18428, 18435, 18442, 18449, 18456, 18463,
18470, 18477, 18484, 18491, 18498, 18505, 18512, 18519, 18526,
18533, 18540, 18547, 18554, 18561, 18568, 18575, 18582, 18589,
18596, 18603, 18610, 18617, 18624, 18631, 18638, 18645, 18652,
18659, 18666, 18673, 18680, 18687, 18694, 18701, 18708, 18715,
18722, 18729, 18736, 18743, 18750, 18757, 18764, 18771, 18778,
18785, 18792, 18799, 18806, 18813, 18820, 18827, 18834, 18841,
18848, 18855, 18862, 18869, 18876, 18883, 18890, 18897, 18904,
18911, 18918, 18925, 18932, 18939, 18946, 18953, 18960, 18967,
18974, 18981, 18988, 18995, 19002, 19009, 19016, 19023, 19030,
19037, 19044, 17896, 17903, 17910, 17917, 17924, 17931, 17938,
17945, 17952, 17959, 17966, 17973, 17980, 17987, 17994, 18001,
18008, 18015, 18022, 18029, 18036, 18043, 18050, 18057, 18064,
18071, 18078, 18085, 18092, 18099, 18106, 18113, 18120, 18127,
18134, 18141, 18148, 18155, 18162, 18169, 18176, 18183, 18190,
18197, 18204, 18211, 18218, 18225, 18232, 18239, 18246, 18253,
18260, 18267, 18274, 18281, 18288, 18295, 18302, 18309, 18316,
18323, 18330, 18337, 18344, 18351, 18358, 18365, 18372, 18379,
18386, 18393, 18400, 18407, 18414, 18421, 18428, 18435, 18442,
18449, 18456, 18463, 18470, 18477, 18484, 18491, 18498, 18505,
18512, 18519, 18526, 18533, 18540, 18547, 18554, 18561, 18568,
18575, 18582, 18589, 18596, 18603, 18610, 18617, 18624, 18631,
18638, 18645, 18652, 18659, 18666, 18673, 18680, 18687, 18694,
18701, 18708, 18715, 18722, 18729, 18736, 18743, 18750, 18757,
18764, 18771, 18778, 18785, 18792, 18799, 18806, 18813, 18820,
18827, 18834, 18841, 18848, 18855, 18862, 18869, 18876, 18883,
18890, 18897, 18904, 18911, 18918, 18925, 18932, 18939, 18946,
18953, 18960, 18967, 18974, 18981, 18988, 18995, 19002, 19009,
19016, 19023, 19030, 19037, 19044), week_start = 1, class = c("yearweek",
"vctrs_vctr"))), class = c("grouped_ts", "grouped_df", "tbl_ts",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -330L), key = structure(list(
`Ship-To.Party` = c("A442", "C100"), .rows = structure(list(
1:165, 166:330), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -2L), .drop = TRUE), index = structure("Week.1", ordered = TRUE), index2 = "Week.1", interval = structure(list(
year = 0, quarter = 0, month = 0, week = 1, day = 0, hour = 0,
minute = 0, second = 0, millisecond = 0, microsecond = 0,
nanosecond = 0, unit = 0), .regular = TRUE, class = c("interval",
"vctrs_rcrd", "vctrs_vctr")), groups = structure(list(`Ship-To.Party` = c("A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "A442", "A442", "A442", "A442",
"A442", "A442", "A442", "A442", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100", "C100", "C100", "C100", "C100", "C100", "C100", "C100",
"C100"), Week.1 = structure(c(17896, 17903, 17910, 17917, 17924,
17931, 17938, 17945, 17952, 17959, 17966, 17973, 17980, 17987,
17994, 18001, 18008, 18015, 18022, 18029, 18036, 18043, 18050,
18057, 18064, 18071, 18078, 18085, 18092, 18099, 18106, 18113,
18120, 18127, 18134, 18141, 18148, 18155, 18162, 18169, 18176,
18183, 18190, 18197, 18204, 18211, 18218, 18225, 18232, 18239,
18246, 18253, 18260, 18267, 18274, 18281, 18288, 18295, 18302,
18309, 18316, 18323, 18330, 18337, 18344, 18351, 18358, 18365,
18372, 18379, 18386, 18393, 18400, 18407, 18414, 18421, 18428,
18435, 18442, 18449, 18456, 18463, 18470, 18477, 18484, 18491,
18498, 18505, 18512, 18519, 18526, 18533, 18540, 18547, 18554,
18561, 18568, 18575, 18582, 18589, 18596, 18603, 18610, 18617,
18624, 18631, 18638, 18645, 18652, 18659, 18666, 18673, 18680,
18687, 18694, 18701, 18708, 18715, 18722, 18729, 18736, 18743,
18750, 18757, 18764, 18771, 18778, 18785, 18792, 18799, 18806,
18813, 18820, 18827, 18834, 18841, 18848, 18855, 18862, 18869,
18876, 18883, 18890, 18897, 18904, 18911, 18918, 18925, 18932,
18939, 18946, 18953, 18960, 18967, 18974, 18981, 18988, 18995,
19002, 19009, 19016, 19023, 19030, 19037, 19044, 17896, 17903,
17910, 17917, 17924, 17931, 17938, 17945, 17952, 17959, 17966,
17973, 17980, 17987, 17994, 18001, 18008, 18015, 18022, 18029,
18036, 18043, 18050, 18057, 18064, 18071, 18078, 18085, 18092,
18099, 18106, 18113, 18120, 18127, 18134, 18141, 18148, 18155,
18162, 18169, 18176, 18183, 18190, 18197, 18204, 18211, 18218,
18225, 18232, 18239, 18246, 18253, 18260, 18267, 18274, 18281,
18288, 18295, 18302, 18309, 18316, 18323, 18330, 18337, 18344,
18351, 18358, 18365, 18372, 18379, 18386, 18393, 18400, 18407,
18414, 18421, 18428, 18435, 18442, 18449, 18456, 18463, 18470,
18477, 18484, 18491, 18498, 18505, 18512, 18519, 18526, 18533,
18540, 18547, 18554, 18561, 18568, 18575, 18582, 18589, 18596,
18603, 18610, 18617, 18624, 18631, 18638, 18645, 18652, 18659,
18666, 18673, 18680, 18687, 18694, 18701, 18708, 18715, 18722,
18729, 18736, 18743, 18750, 18757, 18764, 18771, 18778, 18785,
18792, 18799, 18806, 18813, 18820, 18827, 18834, 18841, 18848,
18855, 18862, 18869, 18876, 18883, 18890, 18897, 18904, 18911,
18918, 18925, 18932, 18939, 18946, 18953, 18960, 18967, 18974,
18981, 18988, 18995, 19002, 19009, 19016, 19023, 19030, 19037,
19044), week_start = 1, class = c("yearweek", "vctrs_vctr")),
.rows = structure(list(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L,
54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L,
65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L,
76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L,
87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L,
98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L,
108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L,
117L, 118L, 119L, 120L, 121L, 122L, 123L, 124L, 125L,
126L, 127L, 128L, 129L, 130L, 131L, 132L, 133L, 134L,
135L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 143L,
144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L,
153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L,
162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L,
171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L,
180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L,
189L, 190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L,
198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L,
207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L,
216L, 217L, 218L, 219L, 220L, 221L, 222L, 223L, 224L,
225L, 226L, 227L, 228L, 229L, 230L, 231L, 232L, 233L,
234L, 235L, 236L, 237L, 238L, 239L, 240L, 241L, 242L,
243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L, 251L,
252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 260L,
261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L,
270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L,
279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L,
288L, 289L, 290L, 291L, 292L, 293L, 294L, 295L, 296L,
297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 305L,
306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L,
315L, 316L, 317L, 318L, 319L, 320L, 321L, 322L, 323L,
324L, 325L, 326L, 327L, 328L, 329L, 330L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -330L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE))
CCFvalues<- Df %>% CCF(ADJUSTEDSALESUNITS,Shipment,type = "correlation")
#Plot the cross-correlation
ccf.plot<- Final.Original.df.2 %>% filter(`Ship-To.Party` %in% c("A162")) %>%
lag2.plot(ADJUSTEDSALESUNITS,Shipment,10)
Thank you