tsComplete: Completes a series with data from anothe series or by...

Description Usage Arguments Details Value Examples

View source: R/tsComplete.R

Description

Function to complete a time-indexed series (either ts or zoo) by combining it with another series to avoid NAs. The function has a third argument "fill" to chose whether to leave NA, interpolate or repeate the last value when both vectors are missing.

Usage

1
tsComplete(x, y, fill = "fill")

Arguments

x

main data series (either ts or zoo) to be completed for missing observations.

y

secondary series (either ts or zoo) to use only when missing in the main series.

fill

method to treat NA's after combining x and y, can be "na","fill","interpolate" or "repeat"

Details

Supports both ts and zoo. Converts to zoo if one of the parameters is zoo.

Value

Returns either a ts (default) or zoo object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
a  <- c(NA, 1, 2,NA,NA, 5,NA)
b  <- c(   NA,12,NA,13,NA,15,16)
a2 <- ts(a,start=c(2000,1),freq=4)
b2 <- ts(b,start=c(2000,2),freq=4)
b3 <- zoo::as.zoo(b2)
aa  <- tsComplete(a2)
ab1 <- tsComplete(a2,b2)
ab2 <- tsComplete(a2,b2,fill="na")
ab3 <- tsComplete(a2,b3)
ab4 <- tsComplete(a2,b3,fill="fill")

fcbarbi/macroR documentation built on May 14, 2017, 12:14 a.m.