"Can't recycle" error when using for loop in r - r

I have two data frames which I want to process with a for loop. Their structures are the following:
> m_ivae
structure(list(fecha = structure(c(17805, 17836, 17866, 17897,
17928, 17956, 17987, 18017, 18048, 18078, 18109, 18140, 18170,
18201, 18231, 18262, 18293, 18322, 18353, 18383, 18414, 18444,
18475, 18506, 18536, 18567, 18597, 18628, 18659, 18687, 18718,
18748, 18779, 18809), class = "Date"), IVAE = c(109.19, 110.09,
111.34, 111.84, 112.49, 111.99, 113.11, 111.89, 112.11, 112.75,
113.7, 112.93, 112.43, 114.88, 114.5, 114.93, 115.13, 105.54,
91.71, 87.93, 93.06, 96.74, 103.26, 106.76, 109.6, 110.74, 112,
112.73, 114.97, 115.01, 114.67, 115.78, 114.52, 111.91), `Agricultura, Ganadería, Silvicultura y Pesca` = c(99.58,
98.71, 103.44, 101.83, 101.31, 98.87, 99.06, 99.46, 96.55, 100.47,
98.79, 98.91, 100.17, 101.98, 100.48, 99.64, 96.04, 92.42, 97.21,
96.11, 100.57, 94.82, 99.07, 103.63, 97.34, 97.17, 95.46, 98.46,
101.02, 100.24, 100.6, 99.95, 103.07, 98.23), `Índice de Producción Industrial (IPI): Industrias Manufactureras, Explotación de Minas y Canteras y Otras Actividades Industriales` = c(101.4,
103.4, 105.07, 106.72, 108.45, 107.76, 107.25, 105.75, 107.03,
107.31, 106.61, 106.95, 106.61, 110.18, 108.68, 109.66, 111.32,
100.02, 76.77, 73.46, 81.99, 94.83, 100.64, 104.51, 106.74, 107.04,
108.75, 110.8, 110.59, 111.25, 108.82, 110.03, 111.32, 107.61
), Construcción = c(112.25, 117.5, 121.37, 124.32, 122.64, 121.21,
128.69, 122.28, 126.55, 120.13, 137.47, 129.82, 126.83, 132.92,
131.72, 137.56, 130.89, 117.08, 87.62, 67.49, 79.56, 88.97, 117.57,
110.01, 118.02, 117.61, 121.64, 120.76, 120.99, 118.96, 122.7,
122.59, 101.2, 106.3), `Comercio, Transporte y Almacenamiento, Actividades de Alojamiento y de Servicio de Comidas` = c(112.2,
113.03, 113.03, 115.69, 113.74, 114.7, 115.93, 115.3, 114.25,
115.05, 116.68, 114.84, 114.56, 116.58, 117.77, 119.19, 119.15,
103.41, 76.66, 75.21, 90.32, 91.72, 97.53, 105.21, 110.43, 109.72,
112.41, 114.05, 115.88, 117.29, 115.05, 114.69, 116.79, 109.68
), `Información y Comunicaciones` = c(115.49, 116.57, 116.18,
114.29, 113.92, 113.82, 116.45, 115.96, 114.81, 115.72, 116.07,
115.42, 115.32, 115.59, 114.22, 114.21, 113.05, 112.42, 111.52,
108.77, 113.92, 114.07, 115.02, 115.79, 117.78, 117.02, 119.21,
119.56, 125.27, 123.15, 118.56, 119.68, 120.02, 127.68), `Actividades Financieras y de Seguros` = c(117.96,
122.17, 120.93, 119.53, 121.15, 122.17, 125.01, 121.22, 127.48,
124.1, 124.56, 126.86, 124.59, 129.96, 131.74, 131.56, 138.4,
134.4, 131.6, 127.16, 124.61, 116.65, 120.28, 119.57, 127.23,
138.75, 141.25, 138.8, 138.79, 141.28, 141.62, 143.53, 137.62,
139.72), `Actividades Inmobiliarias` = c(113.31, 113.83, 114.41,
114.69, 114.97, 115.98, 116.2, 116.22, 115.64, 115.79, 115.95,
116.24, 117.6, 117.84, 115.35, 108.98, 105.89, 103.74, 103.16,
102.5, 102.42, 102.41, 104.16, 107.74, 112.87, 116.57, 115.68,
113.47, 112.41, 112.08, 112.42, 112.74, 113.21, 112.56), `Actividades Profesionales, Científicas, Técnicas, Administrativas, de Apoyo y Otros Servicios` = c(111.84,
111.92, 114.11, 116.44, 117.77, 112.96, 114.64, 113.67, 112.33,
115.12, 113.31, 114.14, 115.46, 117.17, 120.57, 124.26, 122.68,
99.51, 86.36, 79.21, 81.56, 83.6, 88.71, 97.76, 98.16, 101.04,
102.68, 108.37, 113.64, 114.82, 115.91, 118.35, 118.74, 109.14
), `Actividades de Administración Pública y Defensa, Enseñanza, Salud y Asistencia Social` = c(110.04,
108.07, 109.24, 105.85, 108.99, 109.12, 109.6, 109.31, 108.63,
111.22, 111.25, 109.67, 107.59, 108.8, 106.9, 105.82, 108.24,
107.71, 106.75, 104.67, 98.47, 102.09, 108.94, 109.34, 110.3,
110.01, 109.3, 107.24, 113.46, 111.17, 113.44, 116.42, 112.98,
114.37)), row.names = c(NA, -34L), class = c("tbl_df", "tbl",
"data.frame"))
> m_ipc
structure(list(fecha = structure(c(17805, 17836, 17866, 17897,
17928, 17956, 17987, 18017, 18048, 18078, 18109, 18140, 18170,
18201, 18231, 18262, 18293, 18322, 18353, 18383, 18414, 18444,
18475, 18506, 18536, 18567, 18597, 18628, 18659, 18687, 18718,
18748, 18779, 18809, 18840, 18871), class = "Date"), `Índice General` = c(113.02,
112.82, 112.3, 112.24, 112.44, 112.69, 112.87, 113.01, 112.85,
112.56, 112.16, 111.99, 112.04, 112.17, 112.29, 112.15, 112,
112.09, 111.69, 111.94, 112.59, 112.49, 111.82, 111.56, 111.81,
111.98, 112.2, 112.49, 113.19, 114.08, 114.81, 114.84, 115.51,
116.36, 116.63, 117.1), `Alimentos y Bebidas no Alcohólicas` = c(120.22,
120.56, 120.44, 120.81, 121.12, 121.39, 121.71, 122.29, 122.61,
121.82, 120.79, 120.64, 121.08, 121.48, 121.88, 122.35, 122.22,
122.68, 124.24, 125.06, 126.14, 125.84, 123.33, 122.36, 121.89,
122.24, 122.33, 122.5, 123.12, 124.09, 124.19, 123.97, 124.85,
125.76, 125.93, 127.18), `Bebidas Alcohólicas, Tabaco` = c(146,
145.59, 145.84, 147.3, 146.86, 146.84, 147.11, 147.74, 148.21,
149.24, 150.04, 150.05, 150.11, 149.9, 150.54, 151.89, 151.81,
152.29, 152.01, 153.09, 152.72, 154.65, 154.56, 152.64, 153.4,
153.59, 153.87, 154.49, 155.21, 155.63, 155.4, 155.2, 156.36,
156.2, 156, 157.11), `Prendas de Vestir y Calzado` = c(92.82,
92.77, 92.74, 92.76, 92.93, 92.89, 92.9, 92.69, 92.57, 92.42,
92.13, 91.42, 91.44, 91.17, 91.03, 91.09, 91.43, 91.88, 91.84,
91.84, 91.84, 91.84, 91.84, 92.05, 92.55, 92.6, 92.75, 93, 93.5,
93.84, 93.98, 94.35, 94.5, 94.71, 94.86, 94.85), `Alojamiento, Agua, Electricidad, Gas y otros Combustibles` = c(140.49,
139.57, 138.12, 137.52, 137.35, 137.51, 136.16, 135.75, 135.34,
134.77, 134.82, 134.79, 133.85, 134.04, 134.93, 132.51, 131.61,
131.68, 131.02, 131.03, 131.83, 129.07, 128.61, 129, 131.34,
131.41, 131.97, 132.01, 134.25, 135.03, 137.66, 136.74, 136.96,
140.04, 141.58, 141.93), `Muebles, Artículos para el Hogar y para la Conservación Ordinaria del Hogar` = c(100.24,
100.36, 100.14, 100.29, 100.52, 100.16, 100.25, 100.3, 99.86,
99.73, 99.64, 99.63, 99.48, 99.16, 98.94, 99.16, 99.54, 99.98,
100.08, 100.13, 100.02, 99.83, 100.23, 100.39, 100.07, 100.17,
100.92, 101, 101.98, 102.74, 103.46, 103.81, 104.38, 105.06,
105.3, 106.45), Salud = c(99.37, 99.28, 99.29, 99.29, 99.27,
99.27, 99.34, 99.44, 99.54, 99.6, 99.77, 100.06, 100.07, 100.14,
100.12, 100.17, 100.01, 99.98, 99.96, 100.19, 100.22, 100.9,
100.97, 101.13, 101.24, 101.9, 101.88, 102.04, 102.93, 103.14,
103.37, 103.83, 104.14, 104.19, 104.45, 104.53), Transporte = c(112.15,
110.75, 108.27, 106.83, 107.41, 108.94, 111.01, 111.41, 110.51,
110.51, 109.34, 108.64, 109.05, 109.47, 108.79, 108.56, 107.88,
106.73, 100.48, 100.6, 102.77, 104.29, 103.76, 103.45, 103.59,
103.53, 103.64, 105.12, 105.76, 109.23, 111.09, 111.72, 112.93,
113.5, 112.71, 112.13), Comunicaciones = c(84.77, 84.69, 84.69,
84.64, 84.32, 84.32, 84.32, 84.31, 84.1, 83.78, 83.78, 83.78,
83.89, 83.89, 83.7, 83.2, 83.16, 83.16, 83.2, 83.17, 83.17, 82.99,
82.99, 83.03, 83.19, 83.19, 83.17, 83.12, 83.12, 83.12, 83.12,
83.11, 83.11, 83.09, 83.09, 83.09), `Recreación y Cultura` = c(87.35,
87.37, 87.4, 87.77, 88.71, 88.48, 88.72, 88.75, 88.08, 88.14,
88.18, 87.97, 87.81, 87.72, 87.58, 87.63, 87.89, 87.74, 87.67,
87.6, 87.65, 87.81, 88.29, 87.68, 88.02, 88.08, 88.14, 88.06,
87.86, 88.11, 88.51, 88.77, 89.12, 89.11, 88.98, 89.14), Educación = c(112.83,
112.83, 112.83, 113.27, 113.27, 113.27, 113.27, 113.27, 113.27,
113.27, 113.27, 113.27, 113.65, 113.65, 113.65, 114.06, 114.06,
114.06, 114.06, 114.06, 114.06, 114.06, 114.06, 114.06, 114.26,
114.26, 114.26, 114.26, 114.26, 114.26, 114.26, 114.26, 114.26,
114.26, 114.26, 114.26), `Restaurantes y Hoteles` = c(122.94,
122.7, 122.81, 123.41, 123.37, 123.54, 123.49, 123.57, 123.55,
123.63, 123.59, 123.5, 123.58, 123.54, 123.93, 124.32, 124.44,
124.44, 124.5, 124.61, 124.7, 125.04, 125.34, 125.52, 125.52,
125.8, 126.01, 126.36, 126.65, 126.97, 127.49, 127.95, 129.19,
129.73, 130.46, 131.3), `Bienes y Servicios Diversos` = c(107.55,
107.75, 107.6, 107.39, 107.4, 107.55, 107.36, 107.13, 107.22,
107.26, 107.4, 107.48, 107.42, 107.4, 107.3, 107.37, 107.55,
108.21, 108.38, 108.39, 108.46, 109.45, 109.67, 109.42, 109.65,
109.65, 109.99, 110.25, 110.37, 110.19, 110.34, 110.36, 111.16,
111.8, 112.28, 112.23)), row.names = c(NA, -36L), class = c("tbl_df",
"tbl", "data.frame"))
And I am using the following code:
library(janitor)
wide_dataframes = list(m_ivae,m_ipc)
names(wide_dataframes) = c('m_ivae','m_ipc')
for (nm in names(wide_dataframes)){
df = get(nm)
df = clean_names(df)
df[paste0("lag", 1:3)] = lapply(1:3, lag, x=df[,2:ncol(df)])
df[,2:ncol(df)] = apply(df[,2:ncol(df)],2,function(x) as.numeric(as.character(x)))
assign(nm, df)
}
However, after I run the for loop, I get the following error message:
Error: Can't recycle `apply(df[, 2:ncol(df)], 2, function(x) as.numeric(as.character(x)))` (size 40) to size 13.
I tried to fix it by removing the column specifications in the fifth line of the for loop, like this:
for (nm in names(wide_dataframes)){
df = get(nm)
df = clean_names(df)
df[paste0("lag", 1:3)] = lapply(1:3, lag, x=df[,2:ncol(df)])
df = apply(df[,2:ncol(df)],2,function(x) as.numeric(as.character(x)))
assign(nm, df)
}
This solves the error, but removes the first column, which I need to keep in order to perform a left join with a different data frame later on.

The issue seems to be assigning the column names df[paste0("lag", 1:3)] i.e. when we do the lag on the whole data or a part of it df[,2:ncol(df)], the assignment to the lhs of = is not of the same length i.e. it is just of length 3 compared to the original ncol(df)-1. As we are using a for loop, the inner lag can also be in a for loop
for (nm in names(wide_dataframes)){
df <- get(nm)
df <- clean_names(df)
nm1 <- names(df)[2:ncol(df)] # get the names of the columns to be lagged
for(i in 1:3) {
nm2 <- paste0(nm1, "lag", i)
df[nm2] <- lag(df[, nm1], n = i)
}
df[,2:ncol(df)] <- lapply(df[,2:ncol(df)],
function(x) as.numeric(as.character(x)))
assign(nm, df)
}
-checking
> ncol(m_ivae)
[1] 41
> ncol(m_ipc)
[1] 53
compare with original number of columns
> sapply(wide_dataframes, ncol)
m_ivae m_ipc
11 14

Related

Ordering column based on some strings

I have a data in columns I have characters part of which are TRG1, TRG2, TRG3, TRG4 and TRG5
How I can order this data frame based on TRG so that first TRG1 ....finally TRG5 are placed in the columns?
My data is
> dput(head(result))
structure(list(`Sample Name` = c("ACTB", "ATP5F1", "DDX5", "EEF1G",
"GAPDH", "NCL"), `31-10TRG3R` = c(15723, 1682, 16598, 17240,
38686, 10670), `31-11TRG4R` = c(24846, 3294, 25522, 38914, 73022,
14628), `31-12TRG4R` = c(7812, 1326, 5750, 9204, 12352, 5489),
`31-13TRG1R` = c(15332, 1162, 18268, 20875, 62257, 10614),
`31-14TRG4R` = c(7644, 1435, 16822, 13731, 26244, 10548),
`31-15TRG4R` = c(6501, 947, 10320, 7285, 10538, 4638), `31-16TRG4R` = c(5428,
825, 11789, 12018, 6812, 5954), `31-17TRG3R` = c(10074, 1056,
7966, 12489, 26819, 6404), `31-18TRG1R` = c(12487, 567, 13945,
16474, 43309, 11831), `31-19TRG4R` = c(5211, 917, 9144, 8024,
8200, 3935), `31-1TRG3R` = c(9928, 1112, 5726, 6227, 12942,
3644), `31-21TRG3R` = c(6806, 1460, 7472, 12420, 46378, 5871
), `31-22TRG3R` = c(4834, 640, 9807, 7082, 14823, 4594),
`31-23TRG1R` = c(3156, 765, 18034, 18982, 17237, 18880),
`31-24TRG4R` = c(6990, 761, 4440, 2833, 8150, 1340), `31-25TRG2R` = c(60621,
6290, 47502, 135948, 233717, 37583), `31-26TRG3R` = c(4198,
718, 2564, 3830, 5790, 1258), `31-27TRG2R` = c(10815, 1010,
8694, 11868, 18684, 5706), `31-28TRG4R` = c(7980, 1343, 7342,
9874, 14286, 4255), `31-29TRG1R` = c(3854, 748, 9314, 9132,
25546, 7852), `31-2TRG1R` = c(7653, 1495, 12238, 12568, 11296,
11256), `31-30TRG5R` = c(24358, 2091, 15594, 26998, 91442,
20914), `31-31TRG4R` = c(6796, 940, 12752, 11642, 41967,
12922), `31-32TRG2R` = c(127379, 11541, 90020, 74881, 234454,
51464), `31-33TRG1R` = c(4139, 338, 8260, 8650, 13916, 8000
), `31-34TRG3R` = c(37303, 2998, 22122, 30431, 51981, 11737
), `31-35TRG4R` = c(32279, 2718, 42178, 36956, 115962, 21194
), `31-36TRG3R` = c(12424, 1134, 8177, 14462, 20147, 6648
), `31-37TRG2R` = c(7031, 690, 8208, 17495, 28514, 7058),
`31-38TRG3R` = c(3645, 698, 16117, 11122, 25739, 7031), `31-39TRG3R` = c(28273,
2169, 14697, 20890, 68353, 25293), `31-3TRG4R` = c(9250,
1335, 24776, 14674, 31266, 8732), `31-40TRG1R` = c(28858,
2100, 26910, 43331, 104235, 19544), `31-41TRG1R` = c(13980,
1184, 13204, 13624, 47414, 11870), `31-42TRG2R` = c(22697,
2401, 16326, 22962, 40136, 11796), `31-43TRG3R` = c(13820,
797, 16245, 7827, 38292, 6206), `31-44TRG2R` = c(9477, 1244,
7140, 6580, 12457, 5176), `31-45TRG3R` = c(12182, 573, 2818,
3699, 4365, 1639), `31-46TRG1R` = c(5438, 997, 9226, 26045,
17740, 8628), `31-47TRG3R` = c(14419, 1927, 7350, 10375,
15736, 3415), `31-48TRG2R` = c(8758, 1002, 8044, 6677, 17354,
7355), `31-49TRG4R` = c(7738, 792, 13920, 15589, 42536, 14056
), `31-4TRG3R` = c(9947, 1115, 7267, 5957, 13831, 2793),
`31-50TRG4R` = c(6660, 701, 4092, 16796, 7958, 2408), `31-51TRG2R` = c(151880,
16572, 93610, 110556, 303604, 57029), `31-52TRG2R` = c(7184,
1396, 12785, 11124, 13050, 8934), `31-53TRG2R` = c(9012,
1118, 7786, 11482, 19512, 9143), `31-5TRG2R` = c(5479, 440,
8913, 7103, 15886, 5801), `31-6TRG4R` = c(6716, 677, 8812,
12184, 14380, 7684), `31-7TRG3R` = c(16192, 1155, 9405, 11930,
30034, 7726), `31-8TRG1R` = c(11408, 1007, 11396, 20424,
38188, 9570), `31-9TRG1R` = c(9468, 812, 10774, 8504, 15464,
4606)), row.names = c(NA, 6L), class = "data.frame")
>
May be, we extract the digits after the 'TRG' and use that in order
result2 <- result[c(1, order(as.numeric(sub(".*TRG(\\d+)\\D+", "\\1",
names(result)[-1])))+1)]

Change manually the shape of a legend ggplot2

I've been customizing themes, lines, and colors in the following plot
library(dplyr)
library(ggplot2)
library(readr)
library(zoo)
cvper <- read.csv("https://cloud.minsa.gob.pe/s/Y8w3wHsEdYQSZRp/download", stringsAsFactors = FALSE)
nuevos_cvper <- cvper %>%
group_by(FECHA_RESULTADO) %>%
arrange(desc(FECHA_RESULTADO)) %>%
summarize (casos_x_dia= n()) %>%
mutate(media_movil = rollmean(casos_x_dia, k=7, fill = NA, align = "right"))
prueba_legend <- ggplot(nuevos_cvper) +
geom_line(aes (x = FECHA_RESULTADO, y = media_movil, color = "media_movil"), size = 1.5) +
geom_line(aes (x = FECHA_RESULTADO, y = casos_x_dia, color = "casos_x_dia"), linetype = "dashed" ) +
geom_point (aes(x = FECHA_RESULTADO, y = casos_x_dia, color = "casos_x_dia")) +
scale_colour_manual("", values = c("media_movil"="#CF3721", "casos_x_dia"="#31A9B8",
"casos_x_dia"="#31A9B8")) +
theme_bw () + theme(legend.position="bottom")
prueba_legend
It shows a legend with short lines. I want to change those lines to circles. I´ve tried with scale_shape_manual, but it doesn't work. Is there a way?
Since one of the more recent ggplot2 versions (make sure you update via install.packages("ggplot2")), the argument key_glyph= can be used to specify the draw_key function that should be used to draw the legend glyphs for a given geom and aesthetic. See here for some more information and examples of usage; however, I will demonstrate with the following example using mtcars and ggplot2 version 3.3.2:
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
geom_line(key_glyph = "point")
You may notice as I did that the point size is a bit small for my taste. That can be adjusted by using override.aes= via the guide_legend() function specified for the color aesthetic to make those points a bit bigger.
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
geom_line(key_glyph = "point") +
guides(color=guide_legend(override.aes = list(size=3)))
Maybe you are looking for this:
library(ggplot2)
#Data
df2 <- structure(list(FECHA_RESULTADO = structure(c(18327, 18328, 18329,
18330, 18331, 18332, 18333, 18334, 18335, 18336, 18337, 18338,
18339, 18340, 18341, 18342, 18343, 18344, 18345, 18346, 18347,
18348, 18349, 18350, 18351, 18352, 18353, 18354, 18355, 18356,
18357, 18358, 18359, 18360, 18361, 18362, 18363, 18364, 18365,
18366, 18367, 18368, 18369, 18370, 18371, 18372, 18373, 18374,
18375, 18376, 18377, 18378, 18379, 18380, 18381, 18382, 18383,
18384, 18385, 18386, 18387, 18388, 18389, 18390, 18391, 18392,
18393, 18394, 18395, 18396, 18397, 18398, 18399, 18400, 18401,
18402, 18403, 18404, 18405, 18406, 18407, 18408, 18409, 18410,
18411, 18412, 18413, 18414, 18415, 18416, 18417, 18418, 18419,
18420, 18421, 18422, 18423, 18424, 18425, 18426, 18427, 18428,
18429, 18430, 18431, 18432, 18433, 18434, 18435, 18436, 18437,
18438, 18439, 18440, 18441, 18442, 18443, 18444, 18445, 18446,
18447, 18448, 18449, 18450, 18451, 18452, 18453, 18454, 18455,
18456, 18457, 18458, 18459, 18460, 18461, 18462, 18463, 18464,
18465, 18466, 18467, 18468, 18469, 18470, 18471, 18472, 18473,
18474, 18475, 18476, 18477, 18478, 18479, 18480, 18481, 18482,
18483, 18484, 18485, 18486, 18487, 18488), class = "Date"), casos_x_dia = c(1,
5, 2, 3, 1, 8, 8, 10, 19, 28, 20, 27, 56, 62, 56, 30, 39, 33,
64, 100, 52, 34, 136, 142, 130, 250, 117, 222, 292, 833, 444,
647, 1042, 1083, 817, 1038, 1404, 738, 1284, 1041, 1383, 1329,
1109, 1407, 1076, 2039, 2171, 2104, 2056, 2239, 2397, 1422, 3399,
3367, 4238, 3372, 2625, 3369, 1922, 3990, 3969, 3634, 3612, 3297,
2469, 936, 3601, 4348, 4441, 3739, 4304, 4125, 1785, 5130, 5198,
5290, 5514, 6100, 5399, 1792, 6968, 6919, 7371, 6425, 5745, 4613,
2262, 4242, 3774, 2614, 4029, 4944, 4764, 2637, 4743, 5310, 5726,
5069, 4661, 4500, 2441, 4363, 3376, 3915, 3436, 3447, 3526, 1446,
4335, 3768, 4109, 4154, 4331, 3526, 1598, 2729, 3748, 3648, 3349,
3862, 3518, 2299, 3783, 4035, 2598, 2495, 4913, 4246, 2380, 3114,
4194, 4432, 4535, 5141, 5066, 2228, 3756, 4815, 5972, 5474, 5960,
5626, 2950, 7071, 3017, 6721, 7248, 7601, 6697, 3194, 7818, 7754,
7508, 8442, 7407, 6759, 3491, 7679, 8473, 8560, 7590, 4805),
media_movil = c(NA, NA, NA, NA, NA, NA, 4, 5.28571428571429,
7.28571428571429, 11, 13.4285714285714, 17.1428571428571,
24, 31.7142857142857, 38.2857142857143, 39.8571428571429,
41.4285714285714, 43.2857142857143, 48.5714285714286, 54.8571428571429,
53.4285714285714, 50.2857142857143, 65.4285714285714, 80.1428571428571,
94, 120.571428571429, 123, 147.285714285714, 184.142857142857,
283.714285714286, 326.857142857143, 400.714285714286, 513.857142857143,
651.857142857143, 736.857142857143, 843.428571428571, 925,
967, 1058, 1057.85714285714, 1100.71428571429, 1173.85714285714,
1184, 1184.42857142857, 1232.71428571429, 1340.57142857143,
1502, 1605, 1708.85714285714, 1870.28571428571, 2011.71428571429,
2061.14285714286, 2255.42857142857, 2426.28571428571, 2731.14285714286,
2919.14285714286, 2974.28571428571, 3113.14285714286, 3184.57142857143,
3269, 3355, 3268.71428571429, 3303, 3399, 3270.42857142857,
3129.57142857143, 3074, 3128.14285714286, 3243.42857142857,
3261.57142857143, 3405.42857142857, 3642, 3763.28571428571,
3981.71428571429, 4103.14285714286, 4224.42857142857, 4478,
4734.57142857143, 4916.57142857143, 4917.57142857143, 5180.14285714286,
5426, 5723.28571428571, 5853.42857142857, 5802.71428571429,
5690.42857142857, 5757.57142857143, 5368.14285714286, 4918.85714285714,
4239.28571428571, 3897, 3782.57142857143, 3804.14285714286,
3857.71428571429, 3929.28571428571, 4148.71428571429, 4593.28571428571,
4741.85714285714, 4701.42857142857, 4663.71428571429, 4635.71428571429,
4581.42857142857, 4305.14285714286, 4046.42857142857, 3813.14285714286,
3639.71428571429, 3500.57142857143, 3358.42857142857, 3354.42857142857,
3410.42857142857, 3438.14285714286, 3540.71428571429, 3667,
3667, 3688.71428571429, 3459.28571428571, 3456.42857142857,
3390.57142857143, 3275.57142857143, 3208.57142857143, 3207.42857142857,
3307.57142857143, 3458.14285714286, 3499.14285714286, 3349.14285714286,
3227.14285714286, 3377.28571428571, 3481.28571428571, 3492.85714285714,
3397.28571428571, 3420, 3682, 3973.42857142857, 4006, 4123.14285714286,
4101.42857142857, 4193.14285714286, 4281.85714285714, 4501.85714285714,
4636, 4753, 4833, 4936.14285714286, 5409.71428571429, 5152.85714285714,
5259.85714285714, 5513.28571428571, 5747.71428571429, 5900.71428571429,
5935.57142857143, 6042.28571428571, 6719, 6831.42857142857,
7002, 6974.28571428571, 6983.14285714286, 7025.57142857143,
7005.71428571429, 7108.42857142857, 7258.71428571429, 7137,
6765.28571428571)), row.names = c(NA, -162L), class = "data.frame")
The code:
prueba_legend <- ggplot(df2) +
geom_line(aes (x = FECHA_RESULTADO, y = media_movil, color = "media_movil"),
size = 1.5,show.legend = F) +
geom_line(aes (x = FECHA_RESULTADO, y = casos_x_dia, color = "casos_x_dia"),
linetype = "dashed",show.legend = F ) +
geom_point (aes(x = FECHA_RESULTADO, y = casos_x_dia, color = "casos_x_dia")) +
scale_colour_manual("", values = c("media_movil"="#CF3721", "casos_x_dia"="#31A9B8",
"casos_x_dia"="#31A9B8")) +
theme_bw () + theme(legend.position="bottom")
prueba_legend
Output:

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))

How do I make a single graph of multiple columns from a dataset?

So I have a large dataset with the daily price of gold in various currencies. The columns in the dataset are Date, USD, GBP, EURO. I want to represent each currency in a single graph. I have this so far:
p1 <- ggplot(data = GOLD) +
geom_line(aes(x = Date, y = USD, GBP, EURO), col ="red") +
labs(title = "Daily price of Gold",
x = "Date", y = "Price in Various Currencies")
But, having y represent each of the currencies is erroring out.
If this is the structure of your data frame, called gold:
str(gold)
'data.frame': 602 obs. of 5 variables:
$ Date: Date, format: "1969-12-31" "1970-01-30" "1970-02-27" "1970-03-31" ...
$ USD : num 35.2 35 35 35.3 35.9 ...
$ EUR : num 22.2 23.2 23.3 23.4 23.8 ...
$ GBP : num 14.7 14.5 14.6 14.7 14.9 ...
$ JPY : num 12592 12496 12530 12628 12858 ...
Then the following commands will produce the desired graph:
library(tidyr) # Needed to reshape the data to longer format
library(ggplot2) # Needed to plot the data
library(scales) # Needed to modify the y-axis tick labels
gold %>%
pivot_longer(cols=USD:JPY, names_to="Currency", values_to="Price") %>%
ggplot(aes(x = Date, y = Price, color=Currency)) +
geom_line() +
labs(title = "Daily price of gold",
x = "Date", y = "Price in various currencies") +
scale_y_log10(labels=comma) # Otherwise you get scientific notation
Data: (available from https://www.gold.org/goldhub/data/gold-prices)
gold <- structure(list(Date = structure(c(-1, 29, 57, 89, 119, 148, 180,
211, 242, 272, 302, 333, 364, 393, 421, 454, 484, 515, 545, 575,
607, 637, 666, 698, 729, 760, 789, 820, 848, 881, 911, 942, 973,
1002, 1034, 1064, 1093, 1126, 1154, 1184, 1215, 1246, 1275, 1307,
1338, 1366, 1399, 1429, 1460, 1491, 1519, 1548, 1580, 1611, 1639,
1672, 1702, 1733, 1764, 1793, 1825, 1856, 1884, 1915, 1945, 1975,
2006, 2037, 2066, 2098, 2129, 2157, 2190, 2220, 2248, 2281, 2311,
2342, 2372, 2402, 2434, 2464, 2493, 2525, 2556, 2587, 2615, 2646,
2675, 2707, 2737, 2766, 2799, 2829, 2860, 2890, 2920, 2952, 2980,
3011, 3039, 3072, 3102, 3133, 3164, 3193, 3225, 3255, 3284, 3317,
3345, 3375, 3406, 3437, 3466, 3498, 3529, 3557, 3590, 3620, 3651,
3682, 3711, 3742, 3772, 3802, 3833, 3864, 3893, 3925, 3956, 3984,
4017, 4047, 4075, 4107, 4137, 4166, 4198, 4229, 4260, 4290, 4320,
4351, 4382, 4411, 4439, 4472, 4502, 4533, 4563, 4593, 4625, 4655,
4684, 4716, 4747, 4778, 4806, 4837, 4866, 4898, 4928, 4957, 4990,
5020, 5051, 5081, 5111, 5143, 5172, 5202, 5233, 5264, 5293, 5325,
5356, 5384, 5417, 5447, 5478, 5509, 5537, 5566, 5598, 5629, 5657,
5690, 5720, 5751, 5782, 5811, 5843, 5874, 5902, 5933, 5963, 5993,
6024, 6055, 6084, 6116, 6147, 6175, 6208, 6238, 6266, 6298, 6328,
6357, 6389, 6420, 6451, 6481, 6511, 6542, 6573, 6602, 6633, 6664,
6693, 6725, 6755, 6784, 6817, 6847, 6878, 6908, 6938, 6970, 6998,
7029, 7057, 7090, 7120, 7151, 7182, 7211, 7243, 7273, 7302, 7335,
7363, 7393, 7424, 7455, 7484, 7516, 7547, 7575, 7608, 7638, 7669,
7700, 7728, 7757, 7789, 7820, 7848, 7881, 7911, 7942, 7973, 8002,
8034, 8065, 8093, 8125, 8155, 8184, 8216, 8247, 8278, 8308, 8338,
8369, 8400, 8429, 8457, 8490, 8520, 8551, 8581, 8611, 8643, 8673,
8702, 8734, 8765, 8796, 8824, 8855, 8884, 8916, 8946, 8975, 9008,
9038, 9069, 9099, 9129, 9161, 9189, 9220, 9248, 9281, 9311, 9342,
9373, 9402, 9434, 9464, 9493, 9526, 9555, 9584, 9616, 9647, 9675,
9708, 9738, 9769, 9800, 9829, 9861, 9892, 9920, 9951, 9981, 10011,
10042, 10073, 10102, 10134, 10165, 10193, 10226, 10256, 10284,
10316, 10346, 10375, 10407, 10438, 10469, 10499, 10529, 10560,
10591, 10620, 10648, 10681, 10711, 10742, 10772, 10802, 10834,
10864, 10893, 10925, 10956, 10987, 11016, 11047, 11075, 11108,
11138, 11169, 11200, 11229, 11261, 11291, 11320, 11353, 11381,
11411, 11442, 11473, 11502, 11534, 11565, 11593, 11626, 11656,
11687, 11718, 11746, 11775, 11807, 11838, 11866, 11899, 11929,
11960, 11991, 12020, 12052, 12083, 12111, 12142, 12172, 12202,
12233, 12264, 12293, 12325, 12356, 12384, 12417, 12447, 12475,
12508, 12538, 12569, 12599, 12629, 12661, 12691, 12720, 12752,
12783, 12814, 12842, 12873, 12902, 12934, 12964, 12993, 13026,
13056, 13087, 13117, 13147, 13179, 13207, 13238, 13266, 13299,
13329, 13360, 13391, 13420, 13452, 13482, 13511, 13544, 13572,
13602, 13633, 13664, 13693, 13725, 13756, 13784, 13817, 13847,
13878, 13909, 13938, 13969, 13999, 14029, 14060, 14091, 14120,
14152, 14183, 14211, 14244, 14274, 14302, 14334, 14364, 14393,
14425, 14456, 14487, 14517, 14547, 14578, 14609, 14638, 14666,
14699, 14729, 14760, 14790, 14820, 14852, 14882, 14911, 14943,
14974, 15005, 15033, 15064, 15093, 15125, 15155, 15184, 15217,
15247, 15278, 15308, 15338, 15370, 15399, 15429, 15460, 15491,
15520, 15552, 15583, 15611, 15644, 15674, 15705, 15736, 15764,
15793, 15825, 15856, 15884, 15917, 15947, 15978, 16009, 16038,
16070, 16101, 16129, 16160, 16190, 16220, 16251, 16282, 16311,
16343, 16374, 16402, 16435, 16465, 16493, 16525, 16555, 16584,
16616, 16647, 16678, 16708, 16738, 16769, 16800, 16829, 16860,
16891, 16920, 16952, 16982, 17011, 17044, 17074, 17105, 17135,
17165, 17197, 17225, 17256, 17284, 17317, 17347, 17378, 17409,
17438, 17470, 17500, 17529, 17562, 17590, 17620, 17651, 17682,
17711, 17743, 17774, 17802, 17835, 17865, 17896, 17927, 17955,
17984, 18016, 18047, 18075, 18108, 18138, 18169, 18200, 18229,
18261, 18292), class = "Date"), USD = c(35.2, 34.99, 35.02, 35.3,
35.85, 35.45, 35.49, 35.3, 35.8, 36.4, 37.25, 37.54, 37.38, 38.05,
38.8, 38.88, 39.7, 40.84, 40.1, 42.4, 40.65, 42.6, 42.34, 43.6,
43.55, 47.15, 48.2, 48.38, 49.6, 59.45, 64.65, 68.3, 66.88, 64.2,
64.39, 63.6, 64.9, 66, 85, 90, 90.72, 114.75, 123.25, 115.6,
103.5, 100, 98, 101, 112.25, 132.5, 162.5, 173, 169.25, 156.75,
144.25, 156, 156, 151.25, 167, 184, 186.5, 175.8, 181.75, 177.25,
167, 167, 166.25, 166.7, 159.8, 141.25, 142.9, 138.15, 140.25,
128.15, 132.3, 129.6, 128.4, 125.5, 123.8, 112.5, 104, 116, 123.15,
130.25, 134.5, 132.3, 142.75, 148.9, 147.25, 142.95, 143, 144.1,
146, 154.05, 161.5, 160.05, 164.95, 175.75, 182.25, 181.6, 170.85,
184.15, 183.05, 200.25, 208.7, 217.1, 242.6, 193.4, 226, 233.7,
251.3, 240.1, 245.3, 274.6, 277.5, 296.45, 315.1, 397.25, 382,
415.65, 512, 653, 637, 494.5, 518, 535.5, 653.5, 614.25, 631.25,
666.75, 629, 619.75, 589.75, 506.5, 489, 513.75, 482.75, 479.25,
426, 406, 425, 428.75, 427, 414.5, 397.5, 387, 362.6, 320, 361.25,
325.25, 317.5, 342.9, 411.5, 397, 423.25, 436, 456.9, 499.5,
408.5, 414.75, 429.25, 437.5, 416, 422, 414.25, 405, 382, 405,
382.4, 373.75, 394.25, 388.5, 375.8, 384.25, 373.05, 342.35,
348.25, 343.75, 333.5, 329, 308.3, 306.65, 287.75, 329.25, 321.35,
314, 317.75, 327.5, 333.25, 325.75, 325.1, 325.3, 326.8, 350.5,
338.15, 344, 345.75, 343.2, 346.75, 357.5, 384.7, 423.2, 401,
389.5, 388.75, 400.5, 405.85, 421, 453.25, 451, 447.3, 462.5,
453.4, 459.5, 468.8, 492.5, 484.1, 458, 426.15, 456.95, 449,
455.5, 436.55, 436.8, 427.75, 396.7, 412.4, 422.6, 410.25, 394,
387, 383.2, 377.55, 361.8, 373, 368.3, 359.8, 366.5, 375.3, 408.15,
398.6, 415.05, 407.7, 368.5, 367.75, 363.05, 352.2, 372.3, 387.75,
408.4, 379.5, 384.85, 386.2, 366, 362.7, 355.65, 357.75, 360.4,
368.35, 362.85, 347.4, 354.9, 357.45, 366.3, 353.15, 354.1, 353.1,
341.7, 336.35, 337.5, 343.4, 357.85, 340, 349, 339.25, 334.2,
332.9, 330.45, 327.6, 337.8, 354.3, 377.45, 378.45, 401.75, 371.55,
355.5, 369.6, 370.9, 391.75, 377.9, 381.55, 389.2, 376.45, 387.6,
388.25, 384, 385.75, 394.85, 383.85, 383.1, 383.25, 374.9, 376.4,
392, 389.75, 384.3, 387.05, 383.35, 382.35, 384, 382.65, 387.8,
387, 405.55, 400.65, 396.35, 391.3, 390.55, 382, 385.3, 386.45,
379, 379.5, 371.3, 369.25, 345.5, 358.6, 348.15, 340.15, 345.6,
334.55, 326.35, 325.35, 332.1, 311.4, 296.8, 290.2, 304.85, 297.4,
301, 310.7, 293.6, 296.3, 288.85, 273.4, 293.85, 292.3, 294.7,
287.8, 285.4, 287.05, 279.45, 286.6, 268.6, 261, 255.6, 254.8,
299, 299.1, 291.35, 290.25, 283.3, 293.65, 276.75, 275.05, 272.25,
288.15, 276.75, 277, 273.65, 264.5, 269.1, 274.45, 264.5, 266.7,
257.7, 263.15, 267.5, 270.6, 265.9, 273, 293.1, 278.75, 275.5,
276.5, 282.3, 296.85, 301.4, 308.2, 326.6, 318.5, 304.65, 312.8,
323.7, 316.9, 319.05, 347.2, 367.5, 347.45, 334.85, 336.75, 361.4,
346, 354.75, 375.6, 388, 386.25, 398.35, 416.25, 399.75, 395.85,
423.7, 388.5, 393.25, 395.8, 391.4, 407.25, 415.65, 425.55, 453.4,
435.6, 422.15, 435.45, 427.5, 435.7, 414.45, 437.1, 429, 433.25,
473.25, 470.75, 495.65, 513, 568.75, 556, 582, 644, 653, 613.5,
632.5, 623.5, 599.25, 603.75, 646.7, 632, 650.5, 664.2, 661.75,
677, 659.1, 650.5, 665.5, 672, 743, 789.5, 783.5, 833.75, 923.25,
971.5, 933.5, 871, 885.75, 930.25, 918, 833, 884.5, 730.75, 814.5,
869.75, 919.5, 952, 916.5, 883.25, 975.5, 934.5, 939, 955.5,
995.75, 1040, 1175.75, 1087.5, 1078.5, 1108.25, 1115.5, 1179.25,
1207.5, 1244, 1169, 1246, 1307, 1346.75, 1383.5, 1405.5, 1327,
1411, 1439, 1535.5, 1536.5, 1505.5, 1628.5, 1813.5, 1620, 1722,
1746, 1531, 1744, 1770, 1662.5, 1651.25, 1558, 1598.5, 1622,
1648.5, 1776, 1719, 1726, 1657.5, 1664.75, 1588.5, 1598.25, 1469,
1394.5, 1192, 1314.5, 1394.75, 1326.5, 1324, 1253, 1204.5, 1251,
1326.5, 1291.75, 1288.5, 1250.5, 1315, 1285.25, 1285.75, 1216.5,
1164.25, 1182.75, 1206, 1260.25, 1214, 1187, 1180.25, 1191.4,
1171, 1098.4, 1135, 1114, 1142.35, 1061.9, 1060, 1111.8, 1234.9,
1237, 1285.65, 1212.1, 1320.75, 1342, 1309.25, 1322.5, 1272,
1178.1, 1145.9, 1212.8, 1255.6, 1244.85, 1266.45, 1266.2, 1242.25,
1267.55, 1311.75, 1283.1, 1270.15, 1280.2, 1291, 1345.05, 1317.85,
1323.85, 1313.2, 1305.35, 1250.45, 1220.95, 1202.45, 1187.25,
1214.95, 1217.55, 1279, 1323.25, 1319.15, 1295.4, 1282.3, 1295.55,
1409, 1427.55, 1528.4, 1485.3, 1510.95, 1460.15, 1514.75, 1584.2
), EUR = c(22.24, 23.2, 23.26, 23.42, 23.79, 23.54, 23.55, 23.45,
23.58, 23.98, 24.58, 24.71, 24.41, 25.09, 25.58, 25.61, 26.14,
26.9, 26.39, 27.92, 26.1, 27.39, 27.22, 27.93, 27.06, 28.99,
29.51, 29.36, 30.17, 36.01, 39.03, 41.31, 40.23, 38.78, 39.27,
38.71, 39.55, 40.81, 48.14, 51.83, 52.61, 65.04, 67.54, 63.58,
57.35, 54.93, 54.3, 58.89, 65.95, 82.65, 100.08, 100.68, 97.53,
92.29, 85.08, 91.61, 93.61, 90.4, 99.31, 107.71, 106.18, 98.8,
99.58, 98.85, 92.69, 91.82, 92.63, 98.41, 94.56, 85.78, 84.59,
83.49, 84.68, 80.12, 84.37, 85.94, 87.07, 84.52, 83.13, 75.95,
70.12, 78.1, 83.06, 87.92, 90.21, 89.95, 97.08, 102.08, 100.64,
97.73, 97.61, 100.32, 102.04, 107.8, 111.51, 110.18, 110.08,
117.4, 119.82, 118.79, 113.18, 122.76, 120.43, 129.16, 132.48,
135.68, 141.49, 122.4, 137.06, 144.84, 154.64, 148.04, 152.76,
172, 169.03, 179.68, 190.38, 233.23, 231.45, 244.87, 299.12,
385.01, 381.48, 321.56, 317.27, 323.09, 392.72, 372.37, 386.52,
412.83, 404.91, 406.73, 392.41, 363.31, 357.95, 375.1, 369.74,
386.14, 353.4, 346.87, 362.53, 349.87, 347.03, 332.94, 327.48,
327.92, 308.91, 285.71, 318.81, 284.76, 301.04, 315.16, 388.34,
383.37, 416.77, 423.24, 429.9, 486.07, 394.41, 410.93, 430.88,
447.29, 431.65, 456.53, 452.93, 440.9, 416.46, 451.49, 432, 436.19,
428.55, 421.4, 425.18, 437.24, 431.92, 412.65, 419.37, 436.4,
421.37, 423.66, 402.45, 402.82, 400.46, 425.73, 417.93, 403.43,
404.96, 393.64, 399.98, 375.93, 366.57, 353.9, 347.51, 364.1,
328.64, 348.01, 329.63, 350.96, 336.16, 332.15, 349.46, 383.64,
369.82, 345.5, 337.8, 334.76, 338.02, 346.74, 371.84, 375.9,
373.31, 391.91, 374.28, 384.69, 372.16, 371.97, 351.76, 352.89,
330.48, 347.7, 345.58, 360.76, 364.4, 374.62, 369.07, 341.8,
337.87, 336.58, 332.66, 335.74, 321.64, 329.38, 321.84, 324.56,
330.9, 310.91, 318.07, 312.36, 315.19, 332.89, 310.67, 321.26,
316.15, 283.87, 280.65, 280.21, 265.93, 267.8, 278.03, 291.86,
262.61, 264.8, 265.67, 251.05, 256.11, 279.75, 282.52, 288.89,
308.46, 292.89, 280.79, 273.61, 276.67, 277.92, 250.28, 264.7,
268.95, 261.69, 257.99, 251.28, 243.14, 246.81, 224.5, 241.25,
254.97, 261.39, 266.67, 264.28, 270.45, 274.97, 281.13, 300.65,
321.12, 354.79, 318.97, 298.71, 318.85, 327.89, 348.19, 335.18,
332.98, 331.04, 317.52, 325.31, 317.59, 313.37, 313, 314.77,
298.37, 311.1, 308.79, 297.3, 293.58, 291.35, 291.51, 289.94,
287.07, 280.74, 294.95, 288.98, 285.63, 294.55, 290.67, 314.78,
306.5, 304.48, 308.65, 307.01, 298.59, 293.51, 294.9, 296.14,
294.25, 291.75, 290.49, 288.68, 310.07, 297.45, 300.81, 301.56,
296.89, 305.23, 298.45, 298.75, 273.02, 266.62, 266.06, 284.48,
275.71, 284.19, 284.81, 267.29, 272.95, 262.35, 246.34, 251.03,
247.54, 254.8, 245.08, 251.3, 261.48, 258.85, 270.89, 257.55,
253.08, 238.81, 241.22, 280.75, 284.56, 289.35, 289.56, 289.55,
305, 289.22, 301.82, 293.56, 300.59, 298.67, 311.55, 310.08,
312.06, 309.13, 292.31, 284.41, 290.02, 291.52, 296.81, 315.6,
319.63, 303.89, 300.53, 321.84, 309.48, 307.68, 310.53, 327.91,
343.18, 345.48, 342.03, 349.57, 322.5, 310.74, 318.96, 327.53,
320, 320.72, 330.86, 342.34, 322.37, 306.86, 301.75, 307.27,
301.3, 315.18, 342.11, 333.18, 332.26, 332.32, 330, 321.78, 318.59,
344.78, 324.09, 322.03, 325.32, 325.1, 335.1, 334.66, 334.54,
341.15, 320.47, 323.85, 328.06, 328.93, 337.5, 335.65, 361.05,
353.19, 352.28, 392.53, 393.03, 420.42, 434.91, 468.38, 466.35,
480.93, 511.25, 508.39, 479.8, 495.63, 487.09, 473.06, 473.03,
487.87, 479.28, 500.6, 502.82, 497.13, 496.06, 489.8, 481.66,
486.17, 492.94, 522.45, 545.71, 533.77, 570.26, 623.56, 639.94,
589.13, 559.45, 569.96, 590.43, 588.37, 565.8, 629.69, 576.28,
641.89, 625.7, 717.52, 749.58, 690.29, 666.55, 689.18, 666.24,
662.32, 665.83, 681.23, 704.87, 783.13, 757.97, 775.93, 812.08,
824.4, 886.89, 984.07, 1015.59, 897.3, 980.37, 957.37, 968.96,
1062.8, 1047.67, 967.91, 1021.58, 1014.02, 1034.98, 1068.8, 1038.38,
1133.26, 1259.55, 1207.42, 1234.59, 1297.03, 1179.37, 1332.26,
1323.17, 1248.4, 1247.59, 1260.06, 1259.6, 1317.04, 1307.81,
1380.49, 1326.59, 1327.08, 1257.21, 1226.43, 1215.05, 1244.65,
1114.23, 1076, 917.03, 989.95, 1057.75, 979.94, 973.89, 920.28,
874.12, 927.66, 960.43, 937.24, 929.28, 916.42, 960.45, 960.58,
976.12, 962.99, 929.24, 948.74, 996.65, 1116.8, 1082.33, 1105.21,
1053.28, 1086.7, 1050.98, 994.16, 1012.94, 997.99, 1034.13, 1005.44,
975.79, 1027.49, 1136.53, 1085.52, 1122.5, 1088.79, 1188.85,
1200.09, 1175.53, 1176.81, 1160.37, 1110.58, 1086.42, 1122.24,
1181.63, 1163.9, 1163, 1126.01, 1089.17, 1075.11, 1103.33, 1085.35,
1090.3, 1073.68, 1075.12, 1079.71, 1080.52, 1076.43, 1086.91,
1118.26, 1071, 1043.5, 1033.48, 1022.17, 1072.28, 1075.34, 1118.84,
1153.21, 1158.47, 1153.67, 1144.2, 1162.61, 1237.27, 1282.15,
1387.88, 1362.41, 1354.32, 1324.28, 1349.44, 1429.53), GBP = c(14.66,
14.54, 14.55, 14.67, 14.93, 14.8, 14.85, 14.81, 14.99, 15.23,
15.6, 15.69, 15.46, 15.75, 16.06, 16.08, 16.41, 16.89, 16.57,
17.53, 16.53, 17.15, 17, 17.48, 17.06, 18.18, 18.49, 18.5, 19,
22.75, 26.45, 27.88, 27.32, 26.53, 27.55, 27.04, 27.66, 27.73,
34.25, 36.3, 36.45, 44.73, 47.76, 46.23, 42.09, 41.43, 40.18,
43.07, 48.32, 58.06, 70.54, 72.23, 69.56, 65.41, 60.44, 65.55,
67.31, 64.84, 71.54, 79.11, 79.36, 73.88, 74.81, 73.84, 70.91,
72.26, 76.49, 77.62, 75.72, 69.15, 68.78, 68.48, 69.32, 63.13,
65.32, 67.61, 69.76, 71.37, 69.36, 63.01, 58.51, 69.84, 77.65,
78.82, 79.04, 77.14, 83.29, 86.57, 85.64, 83.16, 83.14, 82.96,
83.77, 88.15, 87.75, 88.08, 86.05, 90.13, 93.87, 97.32, 93.39,
100.46, 98.41, 103.68, 107.38, 109.84, 116.92, 99.46, 110.7,
117.44, 124.19, 116.22, 118.82, 132.69, 127.29, 131.87, 139.89,
180.36, 184.01, 188.97, 230.63, 288.11, 280.25, 228.51, 229.36,
228.36, 277.32, 262.16, 263.41, 279.27, 258.16, 262.83, 246.65,
213.98, 221.77, 228.89, 225.53, 231.52, 220.67, 220.47, 229.85,
237.53, 229.57, 212.02, 208.22, 205.74, 199.07, 179.57, 201.37,
181.65, 182.1, 197.3, 239.66, 234.29, 252.39, 268.56, 282.47,
328.62, 269.64, 279.58, 275.07, 272.67, 271.9, 277.5, 277.28,
270.54, 255.43, 276.26, 263.45, 266.68, 264.51, 269.32, 268.72,
277.34, 275.01, 261.84, 266.14, 278.34, 273.14, 274.62, 266.01,
271.13, 266.44, 266.06, 258.63, 244.07, 242.56, 232.52, 239.23,
231.19, 225.61, 218.54, 226.08, 248.05, 233.69, 231.81, 222.92,
233.07, 226.26, 239.53, 258.45, 292.47, 285.31, 271.71, 262.23,
264.62, 262.52, 262.31, 272.96, 276.69, 277.22, 290.52, 277.56,
282.68, 272.24, 269.72, 257.71, 258.76, 240.29, 242.03, 238.89,
247.76, 255.59, 255.36, 254.01, 234.59, 233.19, 228.37, 226.78,
225.08, 221.84, 227.01, 223.53, 230.08, 240.8, 221, 228.66, 226.94,
237.83, 260.13, 247.19, 247.05, 241.24, 223.67, 224.31, 216.49,
201.89, 200.16, 204.89, 217.99, 195.22, 198.43, 200.1, 186.26,
189.85, 204.51, 207.51, 212.12, 227.52, 215.34, 206.66, 202.45,
205.14, 207.54, 188.75, 197.82, 200.97, 196.89, 189.55, 184.53,
180.36, 186.38, 171.54, 195.9, 217.12, 220.81, 219.88, 222.23,
230.22, 224.38, 225.81, 241.8, 253.4, 270.54, 249.78, 237.71,
248.64, 249.85, 264.79, 252.13, 256.75, 262.17, 248.27, 256.39,
251.55, 249.91, 251.06, 250.38, 235.41, 244.77, 244.97, 236.16,
238.19, 240.67, 242.19, 241.92, 243.29, 239.58, 246.83, 242.62,
242.51, 253.55, 249.27, 268.4, 261.71, 259.65, 260.77, 252.07,
245.86, 247.45, 247.25, 242.42, 233.05, 220.97, 215.77, 215.6,
219.8, 212.03, 209.63, 211.25, 201.02, 199.3, 200.61, 205.58,
185.7, 176.16, 176.38, 186.45, 180.63, 179.75, 185.83, 180.05,
177.58, 176.56, 163.27, 172.91, 174.54, 178.54, 172.98, 173.73,
179.18, 173.11, 178.01, 167.53, 165.58, 157.78, 158.46, 181.56,
182.28, 182.93, 180.09, 174.78, 186.01, 173.48, 175.78, 182.14,
190.34, 184.79, 190.38, 185.09, 182.16, 189.83, 183.73, 181.03,
184.92, 181.27, 183.92, 188.3, 192.41, 186.58, 188.22, 199.43,
191.67, 193.19, 189.98, 199.75, 209.88, 211.66, 211.49, 223.22,
208.96, 195.02, 202.21, 205.84, 202.56, 205.04, 215.67, 223.58,
220.59, 211.84, 210.7, 220.59, 209.68, 220.69, 237.46, 233.54,
227.61, 231.62, 232.52, 219.61, 213.3, 230.54, 219.08, 214.49,
218.25, 215.24, 226.38, 229.7, 232.25, 237.2, 226.89, 223.82,
226.13, 226.24, 228.13, 227.4, 243.86, 243.67, 240.89, 267.51,
265.92, 286.44, 298.82, 320, 317.49, 335.53, 354.3, 348.96, 331.7,
338.77, 327.79, 320.81, 316.56, 328.77, 322.92, 332.33, 338.92,
337.4, 338.53, 333.2, 324.22, 327.5, 333.16, 364.69, 380.05,
381.05, 418.84, 464.41, 488.39, 469.69, 439.78, 448.21, 467.43,
463.43, 456.7, 496.23, 452.27, 530.81, 604.94, 637.79, 667.91,
639.41, 596.07, 604.94, 567.45, 566.4, 586.27, 622.6, 630.93,
716.44, 673.44, 673.05, 727.96, 735.38, 770.42, 831.07, 831.5,
746.44, 810.72, 829.42, 842.35, 888.37, 897.71, 828.47, 867.51,
897.72, 920.59, 933.5, 937.74, 992.08, 1113.77, 1039.93, 1066.85,
1110.12, 985.14, 1105.16, 1108.02, 1040.53, 1016.87, 1012.25,
1019.16, 1035.23, 1037.87, 1099.83, 1067.01, 1076.97, 1019.69,
1050.02, 1046.48, 1052.55, 943.85, 919.79, 785.92, 867.06, 901.64,
819.13, 824.1, 764.93, 727.25, 761.2, 791.54, 774.83, 763.08,
745.52, 769.07, 761.27, 774.2, 750.39, 727.72, 755.24, 773.45,
839.1, 785.56, 799.6, 768.02, 780.76, 744.58, 703.88, 737.97,
735.44, 739.67, 705.44, 719.18, 783.79, 886.12, 860.64, 877.64,
832.77, 987.99, 1010.77, 999.66, 1018.09, 1041.85, 942.93, 927.37,
963.99, 1009, 995.52, 978.9, 980.83, 956.35, 961.47, 1018.01,
956.36, 956.47, 945.74, 954.35, 945.85, 956.45, 943.72, 953.43,
980.99, 947.13, 930.78, 925.14, 910.43, 950.85, 954.27, 1004.24,
1005.93, 991.77, 994.13, 983.62, 1027.89, 1107.1, 1165.87, 1255,
1205.31, 1167.66, 1128.84, 1143.42, 1201.79), JPY = c(12592.44,
12496.35, 12529.95, 12627.65, 12858.36, 12757.88, 12764.72, 12728.16,
12799.92, 13018.66, 13341.25, 13403.93, 13239.03, 13613.21, 13867.1,
13892.95, 14188.38, 14594.98, 14328.74, 15153.74, 13538.98, 14059.41,
13957.5, 14250.08, 13691.48, 14624.17, 14619.8, 14695.64, 15092.19,
18096.15, 19085.52, 20559.69, 20090.92, 19326.34, 19410.68, 19127.31,
19568.2, 19897.07, 22585.63, 23834.22, 24145.47, 30392.78, 32263.28,
30535.41, 27419.59, 26534.94, 26098.24, 28232.64, 31384.58, 39453.89,
46802.46, 47602.1, 47234.18, 44183.03, 41041.61, 46668.94, 47254.41,
45131.84, 50150.83, 55215.86, 56029.4, 52492.53, 52067.51, 51834.86,
48788.12, 48777.59, 49565.26, 49794.25, 47625.81, 42800.94, 43162.37,
41975.69, 42788.35, 38950.05, 40006.82, 38873.24, 38474.65, 37717.84,
36897.27, 33015.97, 30015.22, 33347.41, 36300.55, 38700.65, 39440.3,
38185.75, 40377.01, 41380.39, 40936.12, 39666.76, 38285.79, 38493.04,
39036.11, 40680.98, 40276.31, 39109.66, 39538.1, 42495.47, 43462.15,
40096.07, 38241.67, 40838.54, 37298.9, 37789.89, 39731.94, 41080.4,
43492.65, 38590.52, 43893.74, 47327.21, 50918.25, 50379.21, 54567.22,
60506.23, 60400.85, 64222.08, 69384.93, 89144.59, 90807.88, 103747.21,
122753.24, 156299.39, 160301.01, 123625.03, 123852.21, 119317.25,
143581.44, 139733.44, 138287.63, 140611.01, 132821.9, 134174.05,
119873.91, 104745.2, 102568.08, 108495.29, 104139.22, 107310.34,
96652.77, 97559.14, 97458.09, 99645.86, 99518.62, 88783.57, 87350.12,
88366.05, 85797.72, 79371.51, 85177.74, 79200.8, 80809.09, 88289.82,
107608.45, 106483.75, 117233.06, 109033.58, 107339.81, 119945.76,
97069.41, 99109.49, 102120.63, 104637.36, 99037.93, 102048.79,
102037.58, 95501.08, 89401.56, 94067.22, 88651.45, 87803.93,
92049.07, 87261.11, 85317.53, 89025.08, 88552.94, 83983.73, 84168.28,
84476.24, 81941.05, 81426.13, 77540.56, 78085.95, 74735.07, 82478.9,
80887.16, 78835.6, 78952.48, 77544.39, 79544.62, 70455.94, 68753.77,
65726.53, 65450.46, 67594.74, 60993.19, 61718.4, 57680.74, 59899.76,
56735.83, 54972.42, 59443.07, 65322.55, 65478.19, 63105.32, 61492.07,
61523.85, 62150.7, 61445.03, 63736.17, 64952.37, 65632.63, 69287.93,
64394.79, 67278.39, 64725.48, 65203.72, 58756.86, 58543.8, 54725.53,
56695.21, 56080.25, 56984.01, 58274.86, 58095.28, 58358.48, 53135.74,
51768.65, 51497.63, 51252.96, 51430.46, 49082.16, 50737.68, 50127.67,
51480.31, 53698.52, 50443.76, 52020.64, 51173.85, 53571.85, 58335.06,
57287.2, 59972.28, 60672.52, 57987.09, 58375.7, 55420.9, 53602.28,
54393.81, 55780.68, 56458.81, 49292.09, 51243.87, 52377.16, 48101.57,
48220.78, 50208.24, 48765.23, 49902.39, 50793.19, 49851.52, 47532.41,
47120.95, 46668.54, 47629.39, 44120.18, 44460.3, 45619.62, 45481.28,
44875.08, 43087.08, 43240.65, 45569.99, 41899.63, 41874.13, 41795.6,
41568.03, 41557.52, 41222.92, 38676.62, 38817.25, 39404.32, 40441.07,
40416.99, 42136.42, 38903.5, 37736.97, 40092.83, 40475.44, 43721.26,
41192.97, 39738.41, 39990.29, 38204.02, 40564.26, 38298.92, 38467.2,
38642.5, 39078.28, 37214.24, 37907.73, 38236.85, 37096.34, 36397.87,
33868.79, 32746.79, 32529.05, 32860.52, 33750.11, 37451.17, 37881.59,
39124.04, 39373.31, 39920.98, 43359.35, 42136.35, 42330.2, 40990.61,
42218.43, 41899.67, 41121.12, 41968.46, 42211.13, 43164.33, 42253.91,
42858.84, 41943.7, 43279.41, 43104.44, 43168.42, 40272.75, 38282.53,
38639.82, 39136.33, 40094.41, 37452.06, 37879.08, 37733.25, 38654.96,
37570.53, 40139.85, 41052.78, 40682.66, 41121.96, 41704.14, 38601.33,
39998.84, 34061.7, 36224.52, 32463.81, 33186.3, 34058.46, 33095.26,
34209.99, 32714.12, 31591.44, 29333.93, 27937.54, 31834.53, 31214.06,
29771.58, 29708.54, 30325.83, 32258.91, 28384.86, 29726.01, 29314.52,
30487.7, 30326.26, 29539.28, 29570.61, 28880.75, 29809.53, 31342.18,
30757.38, 31282.57, 32294.96, 32508.22, 31784.35, 33749.21, 33206.91,
32488.36, 34916.98, 34120.39, 33919.56, 36238.09, 37764.65, 39725.93,
39946.03, 39572.87, 40532.67, 38175.41, 36484.87, 37087.1, 39407.23,
38823.41, 39088.39, 41202.22, 44077.95, 41077.27, 39706.49, 40160.8,
43225.23, 41545.95, 42763.34, 43824.99, 43345.42, 42462.39, 43627.27,
44609.51, 42313.53, 43250.55, 44079.62, 42872.92, 43463.95, 43187.69,
43623.47, 44693.65, 45810.85, 45189.13, 46607.24, 44635.91, 43673.51,
45410.89, 45725.4, 45711.46, 44667.34, 48435.03, 48088.75, 48149.24,
53638.15, 54797.65, 59306.99, 60549.39, 66580.71, 64398.7, 68670.17,
73544.8, 73207.82, 70132.24, 72380.14, 73127.19, 70750.44, 70732.33,
74794.08, 75305.96, 78684.47, 78697.72, 78136.13, 80904.88, 80288.24,
80333.49, 79237.75, 77894.88, 85456.14, 91017.5, 86909.73, 93142.38,
98164.55, 101138, 92915.91, 91028.21, 93504.19, 98611.14, 99222.02,
90401.32, 93902.94, 71869.26, 77577.05, 78842.83, 82580.29, 93148.43,
90522.69, 86898.55, 93116.34, 90165.22, 89388.1, 88636.96, 89154.46,
94140.79, 101284.97, 101240.8, 97771.42, 98484.63, 104232.31,
110861.29, 109924.75, 110081.55, 101305.53, 104626.6, 109186.77,
108480.7, 115895.78, 113993.07, 108721.1, 115603.22, 119264.31,
124590.47, 124825.25, 121584.17, 125703.89, 138678.32, 124869.58,
134272.93, 135541.96, 117795.12, 132980, 143263.78, 136815.43,
131844.03, 122170.56, 127544.3, 126678.19, 129077.53, 138172.78,
137399.66, 142343.2, 143315.73, 151925.08, 146555, 150267.45,
143095.27, 140809.62, 118407.31, 129287.64, 136845.88, 130162.81,
129897.62, 128263.33, 126598.97, 127583.22, 135389.21, 133030.85,
131620.27, 127232.12, 133216.07, 132168.67, 133570.13, 133443.96,
130518.24, 140374.68, 144593.36, 148035.26, 145127.63, 142350.96,
141240.52, 147846.75, 143289.4, 136086.24, 137544.97, 133418.21,
137853.05, 130911.02, 127512.7, 134600.03, 139389.33, 139032.6,
137558.11, 134427.93, 135495.74, 137534.85, 135422.27, 133922.96,
133668.11, 134238.58, 133652.03, 136530.93, 140482.78, 138713.61,
141171.16, 140022.71, 139579.19, 140057.91, 144371.2, 144432.12,
144327.12, 143260.77, 145431.14, 146818.91, 140621.15, 140791.42,
143696.89, 141819.72, 138506.09, 136673.12, 133333.66, 134853.78,
137113.17, 138252.77, 140325.48, 144009.28, 146847.76, 143381.34,
142816.14, 140664.32, 151805.65, 154996.22, 162231.99, 160523.77,
163341.24, 159901.01, 164615.44, 171703.5)), row.names = c(NA,
-602L), class = "data.frame")

Check date of a year not present in dataset

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")

Resources