sampleZooMonthly: Sample a 'zoo'

Description Usage Arguments Details Value Examples

Description

Sample an input zoo onto a monthly frequency.

Usage

1
sampleZooMonthly(x, register = c("first", "last"))

Arguments

x

An input zoo object

register

Flag to indicate where to register the output: Either 'first' or 'last'

Details

Sub-sample a zoo from (usually) daily to a monthly frequency. Register the output on either first or last day of the month. This simply extracts the records from the input that are closest to either the beginning or ending day of each month covered. It's a "coarsening" of a zoo with a frequency higher than monthly (e.g. daily to monthly).

Value

A zoo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(zoo)

dts1 <- seq(as.Date("2012-08-01"), as.Date("2013-09-30"), "days")
dts2 <- seq(strptime("20120801", "\%Y\%m\%d"),
strptime("20130930", "\%Y\%m\%d"), "day")

nr <- length(dts1)
z1 <- zoo(matrix(rnorm(nr*4), nr, 4), dts1)
z2 <- zoo(matrix(rnorm(nr*4), nr, 4), dts2)

sampleZooMonthly(z1)
sampleZooMonthly(z2, "last")

pchristi99/pcLib documentation built on June 25, 2019, 2:23 p.m.