[R-SIG-Finance] Combining XTS objects with unmatched but regular dates

Worik worik.stanton at gmail.com
Wed Aug 18 06:54:35 CEST 2010


I should have thought harder...

c <- merge(xts(as.numeric(a), as.Date(timeLastDayInMonth(index(a)))), 
xts(as.numeric(b), as.Date(timeLastDayInMonth(index(b)))))


I moved the indexes to the last day of the month...
as.Date(timeLastDayInMonth(index(a)))

cheers
Worik


On 18/08/10 16:34, Worik wrote:
> I have two xts objects
> > head(a)
>                   a
> 2008-12-30 16061.73
> 2009-01-29 14709.56
> 2009-02-26 13148.36
> 2009-03-30 14298.04
> 2009-04-29 15665.30
> 2009-05-28 16540.47
> > head(b)
>               b
> 2008-12-31 0.13
> 2009-01-31 0.30
> 2009-02-28 0.21
> 2009-03-31 0.16
> 2009-04-30 0.18
> 2009-05-31 0.18
>
> I would like to merge them combining the entries on common dates.  
> Just removing the days would be enough.
>
> > head(merge(a,b))
>                   a    b
> 2008-12-30 16061.73   NA
> 2008-12-31       NA 0.13
> 2009-01-29 14709.56   NA
> 2009-01-31       NA 0.30
> 2009-02-26 13148.36   NA
> 2009-02-28       NA 0.21
>
> That is no good.
>
> How can I do this?
>
> cheers
> Worik
>


-- 
You do not have to be blind to not see what is going on right in front of you if it is behind your back
Pascall West
--



More information about the R-SIG-Finance mailing list