## data -
x <- as.timeSeries(data(msft.dat))
## aggregate by weeks
by <- timeSequence(from = start(x), to = end(x), by = "week")
aggregate(x, by, mean)
## aggregate to last Friday of month -
by <- unique(timeLastNdayInMonth(time(x), 5))
aggregate(x, by, mean)
## aggregate to last day of quarter -
by <- unique(timeLastDayInQuarter(time(x)))
aggregate(x, by, mean)
Run the code above in your browser using DataLab