# Synthetic example: aggregate daily synthetic data to monthly means
d <- seq(as.Date("2024-01-01"), as.Date("2024-06-30"), by = "day")
daily <- data.frame(date = d, series_id = "X", value = rnorm(length(d)))
fred_aggregate(daily, fun = "mean", by = "month")
# Wide-format input also works
wide <- data.frame(date = d, A = rnorm(length(d)), B = rnorm(length(d)))
fred_aggregate(wide, fun = "sum", by = "quarter")
# \donttest{
op <- options(fred.cache_dir = tempdir())
try({
if (FALSE) {
daily_yields <- fred_series("DGS10", from = "2023-01-01")
monthly_yields <- fred_aggregate(daily_yields, fun = "mean", by = "month")
}
})
options(op)
# }
Run the code above in your browser using DataLab