#full range of calendar dates
x <- zoo_simulate(
rows = 1000,
time_range = c(
"0000-01-01",
as.character(Sys.Date())
)
)
#plot time series
if(interactive()){
zoo_plot(x)
}
#find valid aggregation keywords
x_time <- zoo_time(x)
x_time$keywords
#mean value by millennia (extreme case!!!)
x_millennia <- zoo_aggregate(
x = x,
new_time = "millennia",
f = mean
)
if(interactive()){
zoo_plot(x_millennia)
}
#max value by centuries
x_centuries <- zoo_aggregate(
x = x,
new_time = "centuries",
f = max
)
if(interactive()){
zoo_plot(x_centuries)
}
#quantile 0.75 value by centuries
x_centuries <- zoo_aggregate(
x = x,
new_time = "centuries",
f = stats::quantile,
probs = 0.75 #argument of stats::quantile()
)
if(interactive()){
zoo_plot(x_centuries)
}
Run the code above in your browser using DataLab