I have a dataset that has daily values. I want to find the monthly average of the values of columns. The following code used to work for me but I don't understand why, it doesn't work anymore. It gives me data1 as 1 obs of 1 variable which is NA.
data %>% group_by(month=floor_date(Timestamp, "month")) %>%
summarize(USDTRY=mean(USDTRY)) -> data1
The following is how my data looks:
dput(head(data))
structure(list(Timestamp = structure(c(1629417600, 1629331200,
1629244800, 1629158400, 1629072000, 1628812800), tzone = "UTC", class = c("POSIXct",
"POSIXt")), USDTRY = c(8.4852, 8.4939, 8.4485, 8.4284, 8.453,
8.5171), EURTRY = c(9.9325, 9.9311, 9.8916, 9.8746, 9.9618, 10.0539
), EURUSD = c(1.1696, 1.1674, 1.171, 1.1708, 1.1777, 1.1791),
BIST100 = c(1444.63, 1439.86, 1449.59, 1461.69, 1455.25,
1447.64), TR2YT = c(18.01, 18.01, 18.01, 18.01, 18.01, 18.15
), TR10YT = c(16.88, 16.87, 16.79, 16.8, 16.69, 16.77), TR_EURBON_2 = c(3.648673,
3.63085, 3.611969, 3.572728, 3.567871, 3.559959), TR_EURBON_10 = c(6.302608,
6.307343, 6.276473, 6.240502, 6.255035, 6.301358), BRENT = c(65.18,
66.45, 68.23, 69.03, 69.51, 70.59), WTI = c(62.32, 63.69,
65.46, 66.59, 67.29, 68.44), Altın = c(1780.8668, 1780.179,
1787.59, 1785.9556, 1787.2383, 1779.1515), Gümüş = c(23.01,
23.23, 23.4805, 23.6351, 23.8235, 23.74)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
Any idea how can I solve it?
Thanks.
(Additionally note that my Timestamp variable has the column values as 2021-08-01, 2021-08-18...
when I view(data)
but it seems as 1629417600, 1629331200
in the dput output.)