keeping common observations of two time series

Viewed 20

I have three xts series. Most of them have common dates in index. But some dates are in one index not in second, some are in second not in third vice versa. I want to keep observations with common elements only. See example want to create a common xts which will include observations of same dates in all three series mean it will include observations from "2002-01-05 to 2002-01-10" of all three series.

library(xts)
library(zoo)
library(lubridate)

date1<-seq(ymd("2002-01-01"),by="day",length.out = 10)
xts1<-xts(rnorm(1:10),order.by = date1)
date2<-seq(ymd("2002-01-03"),by="day",length.out = 10)
xts2<-xts(rnorm(1:10),order.by = date2)
date3<-seq(ymd("2002-01-05"),by="day",length.out = 10)
xts3<-xts(rnorm(1:10),order.by = date3)
common_xts<-


1 Answers

It is very simple.

common_xts<-merge.xts(xts1,xts2,xts3,all=FALSE)

Related