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L, 7L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 
6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 
3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 
5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L), .Label = c("BVG1", "BVG11", 
"BVG12", "BVG13", "BVG14", "BVG15", "BVG16"), class = "factor"), 
    Date = structure(c(16913, 16913, 16913, 16913, 16913, 16913, 
    16913, 16906, 16906, 16906, 16906, 16906, 16906, 16906, 16899, 
    16899, 16899, 16899, 16899, 16899, 16899, 16892, 16892, 16892, 
    16892, 16892, 16892, 16892, 16885, 16885, 16885, 16885, 16885, 
    16885, 16885, 16878, 16878, 16878, 16878, 16878, 16878, 16878, 
    16871, 16871, 16871, 16871, 16871, 16871, 16871, 16864, 16864, 
    16864, 16864, 16864, 16864, 16864, 16857, 16857, 16857, 16857, 
    16857, 16857, 16857, 16850, 16850, 16850, 16850, 16850, 16850, 
    16850, 16843, 16843, 16843, 16843, 16843, 16843, 16843, 16836, 
    16836, 16836, 16836, 16836, 16836, 16836, 16829, 16829, 16829, 
    16829, 16829, 16829, 16829, 16822, 16822, 16822, 16822, 16822, 
    16822, 16822, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 
    16808, 16808, 16808, 16808, 16808, 16808, 16808, 16801, 16801, 
    16801, 16801, 16801, 16801, 16801, 16794, 16794, 16794, 16794, 
    16794, 16794, 16794, 16787, 16787, 16787, 16787, 16787, 16787, 
    16787, 16780, 16780, 16780, 16780, 16780, 16780, 16780, 16773, 
    16773, 16773, 16773, 16773, 16773, 16773, 16766, 16766, 16766, 
    16766, 16766, 16766, 16766, 16759, 16759, 16759, 16759, 16759, 
    16759, 16759, 16752, 16752, 16752, 16752, 16752, 16752, 16752, 
    16745, 16745, 16745, 16745, 16745, 16745, 16745, 16738, 16738, 
    16738, 16738, 16738, 16738, 16738, 16731, 16731, 16731, 16731, 
    16731, 16731, 16731, 16724, 16724, 16724, 16724, 16724, 16724, 
    16724, 16717, 16717, 16717, 16717, 16717, 16717, 16717, 16710, 
    16710, 16710, 16710, 16710, 16710, 16710, 16703, 16703, 16703, 
    16703, 16703, 16703, 16703, 16696, 16696, 16696, 16696, 16696, 
    16696, 16696, 16689, 16689, 16689, 16689, 16689, 16689, 16689, 
    16682, 16682, 16682, 16682, 16682, 16682, 16682, 16675, 16675, 
    16675, 16675, 16675, 16675, 16675, 16668, 16668, 16668, 16668, 
    16668, 16668, 16668, 16661, 16661, 16661, 16661, 16661, 16661, 
    16661, 16654, 16654, 16654, 16654, 16654, 16654, 16654, 16647, 
    16647, 16647, 16647, 16647, 16647, 16647, 16640, 16640, 16640, 
    16640, 16640, 16640, 16640, 16633, 16633, 16633, 16633, 16633, 
    16633, 16633, 16626, 16626, 16626, 16626, 16626, 16626, 16626, 
    16619, 16619, 16619, 16619, 16619, 16619, 16619, 16612, 16612, 
    16612, 16612, 16612, 16612, 16612, 16605, 16605, 16605, 16605, 
    16605, 16605, 16605, 16598, 16598, 16598, 16598, 16598, 16598, 
    16598, 16591, 16591, 16591, 16591, 16591, 16591, 16591, 16584, 
    16584, 16584, 16584, 16584, 16584, 16584, 16577, 16577, 16577, 
    16577, 16577, 16577, 16577, 16570, 16570, 16570, 16570, 16570, 
    16570, 16570, 16563, 16563, 16563, 16563, 16563, 16563, 16563, 
    16556, 16556, 16556, 16556, 16556, 16556, 16556, 16549, 16549, 
    16549, 16549, 16549, 16549, 16549, 16542, 16542, 16542, 16542, 
    16542, 16542, 16542, 16535, 16535, 16535, 16535, 16535, 16535, 
    16535, 16528, 16528, 16528, 16528, 16528, 16528, 16528, 16521, 
    16521, 16521, 16521, 16521, 16521, 16521, 16514, 16514, 16514, 
    16514, 16514, 16514, 16514, 16507, 16507, 16507, 16507, 16507, 
    16507, 16507, 16500, 16500, 16500, 16500, 16500, 16500, 16500, 
    16493, 16493, 16493, 16493, 16493, 16493, 16493, 16486, 16486, 
    16486, 16486, 16486, 16486, 16486, 16479, 16479, 16479, 16479, 
    16479, 16479, 16479, 16472, 16472, 16472, 16472, 16472, 16472, 
    16472, 16465, 16465, 16465, 16465, 16465, 16465, 16465, 16458, 
    16458, 16458, 16458, 16458, 16458, 16458, 16451, 16451, 16451, 
    16451, 16451, 16451, 16451, 16444, 16444, 16444, 16444, 16444, 
    16444, 16444, 16437, 16437, 16437, 16437, 16437, 16437, 16437, 
    16430, 16430, 16430, 16430, 16430, 16430, 16430, 16423, 16423, 
    16423, 16423, 16423, 16423, 16423, 16416, 16416, 16416, 16416, 
    16416, 16416, 16416, 16409, 16409, 16409, 16409, 16409, 16409, 
    16409, 16402, 16402, 16402, 16402, 16402, 16402, 16402, 16395, 
    16395, 16395, 16395, 16395, 16395, 16395, 16388, 16388, 16388, 
    16388, 16388, 16388, 16388, 16381, 16381, 16381, 16381, 16381, 
    16381, 16381, 16374, 16374, 16374, 16374, 16374, 16374, 16374, 
    16367, 16367, 16367, 16367, 16367, 16367, 16367, 16360, 16360, 
    16360, 16360, 16360, 16360, 16360, 16353, 16353, 16353, 16353, 
    16353, 16353, 16353, 16346, 16346, 16346, 16346, 16346, 16346, 
    16346, 16339, 16339, 16339, 16339, 16339, 16339, 16339, 16332, 
    16332, 16332, 16332, 16332, 16332, 16332, 16325, 16325, 16325, 
    16325, 16325, 16325, 16325, 16318, 16318, 16318, 16318, 16318, 
    16318, 16318, 16311, 16311, 16311, 16311, 16311, 16311, 16311, 
    16304, 16304, 16304, 16304, 16304, 16304, 16304, 16297, 16297, 
    16297, 16297, 16297, 16297, 16297, 16290, 16290, 16290, 16290, 
    16290, 16290, 16290, 16283, 16283, 16283, 16283, 16283, 16283, 
    16283, 16276, 16276, 16276, 16276, 16276, 16276, 16276, 16269, 
    16269, 16269, 16269, 16269, 16269, 16269, 16262, 16262, 16262, 
    16262, 16262, 16262, 16262, 16255, 16255, 16255, 16255, 16255, 
    16255, 16255, 16248, 16248, 16248, 16248, 16248, 16248, 16248, 
    16241, 16241, 16241, 16241, 16241, 16241, 16241, 16234, 16234, 
    16234, 16234, 16234, 16234, 16234, 16227, 16227, 16227, 16227, 
    16227, 16227, 16227, 16220, 16220, 16220, 16220, 16220, 16220, 
    16220, 16213, 16213, 16213, 16213, 16213, 16213, 16213, 16206, 
    16206, 16206, 16206, 16206, 16206, 16206, 16199, 16199, 16199, 
    16199, 16199, 16199, 16199, 16192, 16192, 16192, 16192, 16192, 
    16192, 16192, 16185, 16185, 16185, 16185, 16185, 16185, 16185, 
    16178, 16178, 16178, 16178, 16178, 16178, 16178, 16171, 16171, 
    16171, 16171, 16171, 16171, 16171, 16164, 16164, 16164, 16164, 
    16164, 16164, 16164, 16157, 16157, 16157, 16157, 16157, 16157, 
    16157, 16150, 16150, 16150, 16150, 16150, 16150, 16150, 16143, 
    16143, 16143, 16143, 16143, 16143, 16143, 16136, 16136, 16136, 
    16136, 16136, 16136, 16136, 16129, 16129, 16129, 16129, 16129, 
    16129, 16129, 16122, 16122, 16122, 16122, 16122, 16122, 16122, 
    16115, 16115, 16115, 16115, 16115, 16115, 16115, 16108, 16108, 
    16108, 16108, 16108, 16108, 16108, 16101, 16101, 16101, 16101, 
    16101, 16101, 16101, 16094, 16094, 16094, 16094, 16094, 16094, 
    16094, 16087, 16087, 16087, 16087, 16087, 16087, 16087), class = "Date"), 
    Prod_DL = c(3.37, 3.14, 3.39, 3.32, 3.49, 3.55, 3.33, 3.33, 
    3.21, 3.21, 3.27, 3.4, 3.61, 3.28, 3.36, 3.25, 3.29, 3.45, 
    3.33, 3.55, 3.28, 3.4, 3.28, 3.32, 3.39, 3.48, 3.46, 3.44, 
    3.43, 3.23, 3.32, 3.6, 3.51, 3.44, 3.45, 3.36, 3.06, 3.33, 
    3.32, 3.57, 3.45, 3.43, 3.36, 3.04, 3.37, 3.39, 3.57, 3.41, 
    3.41, 3.22, 2.87, 3.32, 3.21, 3.37, 3.45, 3.17, 3.16, 2.94, 
    3.18, 3.21, 3.22, 3.34, 3.12, 3.15, 2.91, 3.01, 3, 3.28, 
    3.47, 3.17, 3.34, 3.03, 3.32, 3.17, 3.28, 3.61, 3.45, 3.42, 
    3.34, 3.53, 3.2, 3.35, 3.65, 3.37, 3.33, 3.14, 3.27, 3.43, 
    3.32, 3.46, 3.33, 3.34, 2.89, 3.43, 3.77, 3.27, 3.49, 3.15, 
    3.32, 2.92, 3.65, 3.26, 3.31, 3.58, 3.17, 3.41, 3.32, 3.33, 
    3.29, 3.4, 3.5, 3.51, 3.47, 3.26, 3.51, 3.4, 3.53, 3.6, 3.45, 
    3.41, 3.26, 3.58, 3.18, 3.46, 3.56, 3.35, 3.39, 3.19, 3.61, 
    3.35, 3.57, 3.46, 3.21, 3.46, 2.95, 3.65, 3.5, 3.44, 3.52, 
    3.46, 3.43, 3.49, 3.45, 3.57, 3.43, 3.47, 3.28, 3.44, 3.42, 
    3.72, 3.49, 3.54, 3.33, 3.27, 3.33, 3.6, 3.43, 3.16, 3.38, 
    3.34, 3.2, 3.46, 3.29, 3.57, 3.48, 3.46, 3.58, 3.29, 3.24, 
    3.19, 3.2, 3.29, 3.33, 3.31, 3.17, 3.33, 3.1, 3.35, 3.12, 
    3.5, 3.45, 3.34, 3.32, 3.18, 3.21, 3.43, 3.44, 3.43, 3.28, 
    3.46, 3.28, 3.3, 3.49, 3.66, 3.64, 3.39, 3.5, 3.26, 3.36, 
    3.47, 3.62, 3.76, 3.44, 3.6, 3.21, 3.43, 3.58, 3.84, 3.8, 
    3.59, 3.65, 3.14, 3.75, 3.62, 3.81, 3.76, 3.65, 3.57, 3.45, 
    3.48, 3.32, 3.79, 3.79, 3.52, 3.6, 3.48, 3.52, 3.58, 3.7, 
    3.77, 3.56, 3.58, 3.31, 3.4, 3.46, 3.72, 3.78, 3.72, 3.59, 
    3.45, 3.51, 3.45, 3.8, 3.73, 3.54, 3.47, 3.27, 3.27, 3.38, 
    3.65, 3.62, 3.59, 3.6, 3.59, 3.51, 3.42, 3.85, 3.75, 3.45, 
    3.49, 3.1, 3.41, 3.66, 3.69, 3.64, 3.44, 3.45, 3.18, 3.37, 
    3.59, 3.59, 3.57, 3.37, 3.43, 3.13, 3.42, 3.4, 3.55, 3.51, 
    3.47, 3.51, 3.34, 3.65, 3.44, 3.63, 3.66, 3.35, 3.55, 3.25, 
    3.49, 3.61, 3.73, 3.58, 3.59, 3.58, 3.39, 3.68, 3.49, 3.74, 
    3.52, 3.62, 3.55, 3.12, 3.44, 3.53, 3.88, 3.67, 3.58, 3.5, 
    3.14, 3.53, 3.57, 3.76, 3.52, 3.49, 3.54, 3.36, 3.62, 3.63, 
    3.74, 3.49, 3.43, 3.43, 3.16, 3.47, 3.54, 3.64, 3.43, 3.37, 
    3.4, 3, 3.34, 3.48, 3.62, 3.48, 3.42, 3.37, 2.99, 3.35, 3.3, 
    3.85, 3.52, 3.3, 3.3, 2.86, 3.24, 3.34, 3.45, 3.5, 3.36, 
    3.4, 3.03, 3.39, 3.32, 3.76, 3.38, 3.49, 3.38, 2.94, 3.26, 
    3.44, 3.8, 3.42, 3.43, 3.35, 2.82, 3.27, 3.51, 3.63, 3.47, 
    3.46, 3.38, 3.01, 3.35, 3.59, 3.6, 3.33, 3.42, 3.38, 3.06, 
    3.18, 3.41, 3.79, 3.47, 3.44, 3.28, 2.88, 3.11, 3.31, 3.67, 
    3.36, 3.35, 3.25, 2.83, 2.98, 3.35, 3.62, 3.37, 3.36, 3.22, 
    2.7, 3.15, 3.29, 3.56, 3.34, 3.22, 3.16, 2.59, 3.06, 3.36, 
    3.53, 3.27, 3.23, 3.23, 2.64, 3.04, 3.36, 3.69, 3.34, 3.44, 
    3.35, 2.93, 3.18, 3.5, 3.77, 3.39, 3.44, 3.35, 2.88, 3.25, 
    3.46, 3.68, 3.53, 3.36, 3.21, 2.73, 3.08, 3.41, 3.67, 3.47, 
    3.15, 3.14, 2.57, 3.08, 3.33, 3.42, 3.43, 3.14, 3.08, 2.57, 
    3.19, 3.22, 3.42, 3.12, 3.12, 3.12, 2.71, 3.05, 3.3, 3.44, 
    3.08, 3.21, 3.09, 2.62, 3.06, 3.21, 3.43, 3.24, 3.14, 3.21, 
    2.77, 3.22, 3.33, 3.37, 3.26, 3.28, 3.37, 3.4, 3.28, 3.45, 
    3.4, 3.32, 3.39, 3.39, 3.17, 3.63, 3.46, 3.44, 3.49, 3.18, 
    3.36, 3.17, 3.16, 3.43, 3.74, 3.39, 3.33, 3.26, 3.08, 3.04, 
    3.27, 3.48, 3.36, 3.32, 3.29, 3.13, 3, 3.32, 3.53, 3.38, 
    3.38, 3.25, 3.31, 3.02, 3.34, 3.41, 3.36, 3.24, 3.27, 3.22, 
    3.01, 3.27, 3.43, 3.47, 3.32, 3.35, 3.1, 3.07, 3.59, 3.61, 
    3.45, 3.34, 3.36, 3.06, 3.18, 3.46, 3.47, 3.45, 3.44, 3.31, 
    3.18, 3.22, 3.36, 3.44, 3.35, 3.27, 3.36, 3.22, 3.29, 3.4, 
    3.53, 3.38, 3.32, 3.34, 3.19, 3.13, 3.48, 3.46, 3.43, 3.34, 
    3.31, 2.92, 3.13, 3.36, 3.43, 3.53, 3.36, 3.35, 2.99, 3.2, 
    3.45, 3.51, 3.5, 3.32, 3.44, 3.14, 3.3, 3.64, 3.66, 3.53, 
    3.33, 3.35, 2.95, 3.1, 3.36, 3.57, 3.55, 3.43, 3.35, 3.1, 
    3.34, 3.32, 3.47, 3.35, 3.39, 3.4, 3.19, 3.27, 3.64, 3.49, 
    3.51, 3.32, 3.31, 3.14, 3.2, 3.3, 3.39, 3.47, 3.31, 3.31, 
    2.99, 3.28, 3.26, 3.36, 3.54, 3.31, 3.29, 2.98, 3.4, 3.25, 
    3.25, 3.45, 3.27, 3.23, 3.12, 3.22, 3.12, 3.38, 3.35, 3.16, 
    3.28, 2.86, 3.22, 3.24, 3.39, 3.44, 3.36, 3.27, 2.81, 3.47, 
    3.32, 3.35, 3.32, 3.22, 3.24, 3.09, 3.27, 3.08, 3.42, 3.31, 
    3.2, 3.3, 2.85, 3.23, 3.3, 3.4, 3.54, 3.29, 3.33, 2.83, 3.35, 
    3.38, 3.44, 3.43, 3.38, 3.31, 3.04, 3.25, 3.4, 3.37, 3.33, 
    3.36, 3.3, 2.8, 3.08, 3.33, 3.37, 3.48, 3.51, 3.25, 3, 3.3, 
    3.2, 3.25, 3.32, 3.28, 3.16, 2.86, 3.21, 3.19, 3.25, 3.21, 
    3.09, 3.21, 2.8, 3.18, 3.23, 3.35, 3.28, 3.26, 3.36, 2.81, 
    3.24, 3.32, 3.5, 3.47, 3.53, 3.27, 2.96, 3.19, 3.28, 3.18, 
    3.43, 3.38, 3.24, 2.92, 3.23, 3.01, 3.33, 3.34, 3.4, 3.22, 
    2.9, 3.07, 3.25, 3.25, 3.39, 3.28, 3.2, 2.87, 3.24, 3.23, 
    3.13, 3.42, 3.23, 3.27, 2.94, 3.31, 3.28, 3.25, 3.33, 3.35, 
    3.19, 2.81, 3.24, 3.14, 3.15, 3.22, 3.33, 3.18, 2.84, 3.19, 
    3.14, 3.22, 3.24, 3.27, 3.24, 2.9, 3.13, 3.21, 3.24, 3.4, 
    3.37, 3.23, 2.82, 3.19, 3.34, 3.26, 3.36, 3.28, 3.27, 2.96, 
    3.23, 3.26, 3.38, 3.36, 3.3, 3.21, 2.83, 3.09, 3.17, 3.36, 
    3.45, 3.21, 3.13, 2.87, 3.08, 3.06, 3.14, 3.32, 3.2, 3.16, 
    2.8, 3.12, 3.19, 3.24, 3.25, 3.2, 3.18, 2.66, 3.06, 3.19, 
    3.36, 3.38, 3.29, 3.15, 2.79, 3.04, 3.26, 3.19, 3.3, 3.23, 
    3.07, 2.7, 3.05, 3.05, 3.28, 3.15, 3.08, 3.05, 2.7, 3.01, 
    3.04, 3.24, 3.24, 3.02, 2.96, 2.49, 2.99, 3.02, 3.23, 3.2, 
    2.9), AVG_DRIVE_MINS_PER_TASK = c(29.12, 29.03, 31.49, 31.64, 
    28.02, 25.48, 29.68, 29.22, 28.92, 32.24, 31.12, 28.64, 25.97, 
    29.08, 29.35, 32.3, 32.68, 27.54, 28.68, 25.55, 30.28, 29.81, 
    30.5, 34.06, 28.56, 29.3, 27.9, 29.02, 30.34, 31.36, 33.23, 
    30.56, 30.06, 27.64, 30.02, 29.06, 28.5, 31.88, 29.69, 27.75, 
    26.41, 29.88, 29.37, 29.29, 30.54, 31.58, 28.2, 29.02, 28.25, 
    31.85, 30.63, 32.12, 39.22, 31.42, 28.15, 32.42, 30.33, 30.52, 
    32.63, 34.44, 29.35, 26.16, 30.38, 29.85, 29.74, 31.04, 34.39, 
    28.51, 26.32, 30.63, 27.94, 31.96, 29.81, 30.17, 26.81, 24.69, 
    26.19, 27.31, 28.91, 27.38, 29.3, 26.26, 24.22, 28.56, 27.41, 
    30.38, 26.79, 27, 27.57, 24.58, 29, 27.62, 30.68, 28.21, 
    24.52, 28.08, 25.84, 29.05, 27.29, 30.8, 25.98, 28.38, 26.16, 
    24.83, 28.37, 27.01, 29.42, 29.14, 27.4, 26.07, 23.68, 27.03, 
    26.74, 31.43, 27.05, 27.52, 25.38, 23.35, 26.51, 27.92, 30.68, 
    29.17, 30, 26.89, 24.77, 27.11, 27.32, 28.98, 28.74, 28.11, 
    26.92, 24.6, 27.26, 27.51, 31.21, 28.01, 28.86, 25.96, 24.44, 
    27.74, 27.94, 26.03, 30.87, 28.77, 29.02, 25.81, 27.97, 28.03, 
    29.34, 28.97, 27.87, 27.18, 27.23, 27.91, 27.87, 27.91, 31.54, 
    27.8, 26.01, 26.65, 27.89, 27.09, 29.89, 26.45, 27.99, 27.47, 
    24.36, 28.52, 28.54, 30.3, 28.9, 27.87, 29.01, 26.64, 29.44, 
    28.35, 29.33, 29.51, 30.59, 27.65, 26.17, 27.9, 28.54, 30.48, 
    30.44, 29.79, 27.84, 26.23, 27.62, 27.02, 29.32, 25.98, 28, 
    25.67, 24.56, 28.87, 26.93, 28.37, 27.43, 27.52, 26.38, 24.96, 
    27.12, 25.96, 30.72, 26.59, 26.39, 24.76, 23.84, 25.14, 24.89, 
    27.84, 24.83, 26.43, 24.72, 22.16, 24.71, 25.51, 28.32, 24.98, 
    27.49, 24.8, 22.35, 26.21, 26.55, 28.69, 26.18, 28.25, 26.61, 
    23.18, 27.44, 25.96, 28.21, 27.06, 27.2, 25.12, 21.98, 26.57, 
    26.06, 28.67, 25.63, 26.43, 25.47, 23.31, 27.16, 26.54, 30, 
    28.78, 26.97, 24.61, 23.39, 26.35, 26.25, 32.37, 25.84, 28.48, 
    23.68, 22.53, 26.85, 26.19, 32.11, 26.11, 27.95, 22.98, 22.74, 
    27.37, 26.42, 31.19, 28.6, 25.81, 24.14, 22.77, 27.16, 26.97, 
    31.58, 28.42, 26.41, 25.97, 23.23, 27.26, 26.54, 32.92, 25.38, 
    26.62, 25, 23.22, 27.65, 26.36, 30.5, 28.68, 25.7, 23.67, 
    23.88, 26.92, 26.23, 29.53, 26, 26.6, 24.84, 24.31, 26.43, 
    26.49, 33.84, 27.58, 26.52, 25.58, 23.46, 25.71, 27.42, 31.4, 
    27.51, 27.39, 25.32, 25.54, 28.28, 26.54, 28.08, 25.69, 26.98, 
    26.28, 24.96, 27.51, 28.3, 29.9, 29.33, 27.14, 28.23, 26.05, 
    29.4, 28.21, 32.97, 29.85, 28.38, 26.13, 26.07, 27.7, 28.11, 
    33.26, 29.61, 28.75, 25.9, 24.38, 27.63, 29.01, 33.86, 31.27, 
    28.27, 27.43, 25.49, 29.38, 27.83, 30.07, 30.49, 28.62, 25.41, 
    26.22, 26.95, 27.79, 28.65, 30.41, 27.6, 25.19, 28.53, 26.72, 
    27.73, 28.03, 30.26, 27.19, 27.82, 25.39, 27.54, 27.39, 30.06, 
    27.11, 26.96, 28.02, 25.62, 27.37, 27.38, 28.81, 30.12, 27.86, 
    26.31, 25.18, 27.11, 28.93, 30.84, 31.43, 32.18, 26.13, 27.19, 
    27.42, 28.33, 29.47, 31.47, 28.64, 27.62, 25.39, 27.57, 27.9, 
    29.52, 29.12, 27.76, 26.39, 26.45, 28.25, 28.82, 32.14, 30, 
    27.74, 26.77, 28.65, 27.09, 28.2, 34.67, 28.95, 26.29, 27.57, 
    26.96, 26.41, 27.13, 31.39, 27.09, 27.08, 27.39, 25.6, 26.07, 
    27.67, 32.53, 28.73, 27.34, 27.28, 24.89, 26.6, 28.03, 31.22, 
    30.02, 28.12, 26.65, 24.91, 27.57, 27.9, 29.64, 27.35, 28.98, 
    30.03, 25.38, 27.11, 28.78, 27.63, 30.79, 29.44, 29.39, 28.43, 
    26.66, 28.17, 31, 31.56, 26.94, 29.09, 26.23, 25.69, 28.05, 
    31, 31.59, 27.41, 26.6, 26.06, 26.52, 28.21, 31.82, 30.12, 
    26.69, 26.93, 26.73, 27.3, 26.64, 30.45, 28.04, 26.13, 27.65, 
    23.7, 25.55, 26.51, 27.05, 25.29, 26, 25.52, 25.85, 27.88, 
    27.41, 27.49, 31.26, 27, 25.72, 25.12, 27.4, 28.73, 30.33, 
    30.01, 30.14, 26.13, 26.42, 28.62, 28, 31.82, 28.97, 28.88, 
    26.5, 25.7, 26.74, 27.95, 31.8, 27.81, 28.49, 25.65, 25.83, 
    28.14, 27.66, 31.93, 28.33, 28.25, 26.78, 25.14, 26.54, 27.54, 
    31.77, 28.97, 26.51, 27.64, 25.5, 26.01, 27.36, 28.68, 30.54, 
    27.06, 27.59, 24.49, 25.86, 27.02, 27.7, 27.82, 27.66, 25.31, 
    24.31, 28.35, 26.1, 28.52, 26.69, 25.05, 25.9, 24.2, 26.29, 
    26.31, 28.72, 29.06, 26.13, 27.1, 22.82, 26.06, 27.02, 32.33, 
    28.15, 26.25, 27.34, 24.24, 25.65, 27.34, 33.7, 27.96, 27.36, 
    26.36, 23.9, 26.45, 26.25, 32.33, 28.17, 24.21, 23.87, 23.55, 
    26.37, 26.53, 30.9, 29.01, 25.92, 24.72, 24.57, 25.36, 26.79, 
    31.49, 26.1, 27.49, 25.52, 24.4, 26.18, 26.66, 31.44, 28.14, 
    25.57, 25.76, 24.39, 25.25, 27.42, 29.78, 31.01, 27.43, 25.57, 
    23.36, 26.95, 25.65, 29.03, 28.68, 25.9, 24.56, 21.62, 25.48, 
    27.03, 31.92, 28.03, 27, 27.06, 23.32, 25.92, 27.68, 34.12, 
    29.84, 29.29, 26.41, 23.18, 25.54, 27.23, 33.2, 27.74, 28.24, 
    25.98, 24.34, 25.58, 27.08, 31.61, 26.59, 27.38, 27.42, 24.39, 
    25.65, 27.4, 33.48, 27.15, 29.51, 27.15, 23.68, 25.91, 26.86, 
    32.27, 28.87, 27.92, 26.15, 22.48, 25.75, 27.15, 34.16, 28.2, 
    26.52, 25.89, 23.51, 26.21, 27.11, 33.38, 29.18, 27.54, 25.33, 
    23.58, 25.76, 27.15, 32.29, 31.01, 27.02, 25.24, 24.9, 25.34, 
    28.21, 33.38, 30.3, 26.25, 27.83, 26.72, 26.02, 29.08, 33.72, 
    31.32, 28.14, 27.12, 26.41, 28.48, 28.37, 31.13, 32.76, 27.81, 
    26.57, 25.51, 27.31, 27.76, 35.06, 32.31, 27.38, 26.84, 22.83, 
    26.74, 28.04, 33, 32.62, 26.47, 28.18, 24.69, 25.72, 28.08, 
    31.62, 31.93, 28.14, 26.82, 24.07, 26.71, 28.3, 31.08, 33.97, 
    25.68, 27.75, 24.6, 27.91, 28.33, 32.52, 31.12, 28.62, 27.75, 
    24.69, 27.22, 27.74, 30.85, 29.93, 28.9, 26.92, 25.53, 26.14, 
    27.56, 30.97, 29.51, 28.4, 26.65, 24.92, 26.76, 27.72, 32.95, 
    30.39, 26.4, 26.81, 24.96, 27.5, 27.67, 30.41, 31.5, 28.2, 
    27.26, 24.21, 26.59, 26.76, 31.21, 30.5, 25.72, 24.96, 22.96, 
    26.74, 27.46, 30.18, 30.85, 29.05, 26.25, 23.89, 26.89, 28.33, 
    31.75, 32.47, 28.34, 26.26, 24.41, 28.78, 29.17, 31.76, 32.51, 
    28.69, 28.64, 25.38, 28.75, 28.91, 31.45, 29.78, 27.54, 29.29, 
    26.19, 29.9, 30.39, 34.85, 32.35, 31.52, 28.61, 27.18, 29.72, 
    29.98, 33.12, 32.27, 29.84, 29.28, 26.69, 30, 31.67, 33.67, 
    34.99, 30.09, 29.71, 29.07, 32.05, 32.24, 37.27, 34.62, 31.71, 
    30.21, 26.97, 32.69, 30.77, 39.73, 31.97, 33.56, 25.22, 25.83, 
    29.89)), .Names = c("Patch", "Date", "Prod_DL", "AVG_DRIVE_MINS_PER_TASK"
), class = c("tbl_dt", "tbl", "data.table", "data.frame"), row.names = c(NA, 
-833L), .internal.selfref = <pointer: 0x0000000005760788>)

我正在尝试在 x-axis 上绘制 Date,在 y-axis 上绘制其余两个变量 "Prod_DL", "AVG_DRIVE_MINS_PER_TASK"。但出现以下错误:

Error: Aesthetics must be either length 1 or the same as the data (119): x, y

我尝试了以下方法:

ggplot() +
  geom_line(data = p2p_dt_SKILL_A[p2p_dt_SKILL_A$Patch %in% c("BVG1"),],
            aes(x = p2p_dt_SKILL_A$Date, y = p2p_dt_SKILL_A$Prod_DL))+ #filter for BVG1 Patch
  geom_line(data = p2p_dt_SKILL_A[p2p_dt_SKILL_A$Patch %in% c("BVG1"),],aes(x = p2p_dt_SKILL_A$Date, y = p2p_dt_SKILL_A$AVG_DRIVE_MINS_PER_TASK,colour="blue"))+ #filter for BVG1 Patch
  geom_smooth() +
  scale_x_date(labels=date_format("%b-%y"),date_breaks ="2 months")

有什么想法吗?

忘记$variableggplot2,你在开头提到了数据框。

ggplot(data = subset(p2p_dt_SKILL_A, Patch == "BVG1"), aes(x = Date, y = Prod_DL)) +
geom_line() + # will plot line for Prod_DL
geom_line(aes(y = AVG_DRIVE_MINS_PER_TASK), color="blue") + # will plot line for AVG_DRIVE_MINS_PER_TASK in blue
geom_smooth() +
scale_x_date(labels=date_format("%b-%y"),date_breaks ="2 months")


另一个使用 reshape2 包中的 melt 的解决方案:

df_BVG1 = data.frame(subset(p2p_dt_SKILL_A, Patch == "BVG1"))

df = melt(df_BVG1[,c("Date", "Prod_DL", "AVG_DRIVE_MINS_PER_TASK")], id = "Date") 

ggplot(df, aes(x = Date, y = value, color = variable)) + 
geom_line() + geom_smooth() + 
scale_x_date(labels=date_format("%b-%y"),date_breaks ="2 months")

使用此解决方案,geom_smooth 对两个变量完成,因为它们都在 ggplot(aes())