Learn R Programming

dsa (version 0.74.18)

Add: Adding xts together

Description

Adding xts together while treating NAs as zeros.

Usage

Add(x, y, ...)

Arguments

x, y

Input time series

...

further time series to be added

Details

Sometimes, if a xts contains missing values, the behaviour of the usual addition-function is not ideal, at least for the purposes of seasonal adjustment of daily time series. This function changes the behaviour.

Examples

Run this code
# NOT RUN {
series1 <- xts::xts(rnorm(5, 5, 5), seq.Date(from=as.Date("2010-01-01"), length.out=5, by="days"))
series2 <- xts::xts(c(3,4,NA, 6,7), seq.Date(from=as.Date("2010-01-01"), length.out=5, by="days"))
Add(series1, series2)
# Compare this to:
series1 + series2
# }

Run the code above in your browser using DataLab