2017年1月26日木曜日

Conver to quarterly data - apply.quarterly

convert monthly data into quarterly data. when monthly data is available in xts format. "apply.monthly" function to convert.

when <monthly_xts_data> is as example,

2016-07-01  529
2016-08-01  472
2016-09-01  530
2016-10-01  453
2016-11-01  454
2016-12-01  444

apply.quarterly(<monthly_xts_data>,mean)

will output quarterly data as the average of data of 3 months belonging to each quarter.

2016-09-01 510.3333
2016-12-01 450.3333

please see below for the case of apply.quarterly(<monthly_xts_data>,last),

2016-09-01  530
2016-12-01  454

mean,max,min,last are confirmed. it can use standard R functions. apply.monthly seems just to provide interface to them. for other terms, use apply.daily, apply.weekly, apply.monthly and apply.yearly.

0 件のコメント: