[R] merging and adding time series
ggrothendieck at gmail.com
Wed Jun 30 23:10:35 CEST 2010
On Wed, Jun 30, 2010 at 4:02 PM, skan <juanpide at gmail.com> wrote:
> I have two series (that can have with different frequencies or with missing
> I merge them and use na.locf, getting a zoo objet with a common index and
> two core columns.
> How can I add this columns getting a new zoo series?
> Any other way of adding two asynchronou series?
z <- zoo(cbind(1:3, 4:6))
z[, 1] + z[, 2]
If x and y are two zoo series you can do this:
x <- zoo(1:3, c(1, 2, 4))
y <- zoo(4:6, c(1, 2, 3))
x + y
and it will automatically merge them when it adds them using all =
FALSE; however, if you use merge explicitly then the default is all =
TRUE or you can override that with merge(..., all = FALSE) so which
way to go depends on what you want. You can also do left and right
joins. See help(merge.zoo)
More information about the R-help