[R] merge.zoo and fill

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jun 30 20:54:25 CEST 2010


On Wed, Jun 30, 2010 at 10:05 AM, Research <risk2009 at ath.forthnet.gr> wrote:
> Hello again,
>
> I merge different zoo time series with prices at different dates. This
> returns a multivariate zoo object with NA's at various points i.e.,
>
> 2010-02-28     NA     NA      NA       NA   850.2  2444.4     NA      NA
>  NA      NA     NA      NA       NA
> 2010-03-01   61.1   55.3    61.5    81.24      NA      NA 1712.2     3.3
> 11139.3   163.7 2242.4  9015.6  109.791
> 2010-03-31     NA     NA      NA       NA   846.5  2439.0     NA      NA
>  NA      NA     NA      NA       NA
> 2010-04-01   66.9   49.4    65.7    84.48      NA      NA 1700.6     3.8
> 11203.0   164.4 2245.7  9064.5  109.887
> 2010-04-30     NA     NA      NA       NA   838.0  2440.0     NA      NA
>  NA      NA     NA      NA       NA
> 2010-05-01   66.6   45.6    65.7    73.84      NA      NA 1705.3     4.0
> 11252.0   165.1 2248.4  9113.9  110.065
>
> Will the "fill" parameter of the zoo.merge() allow a missing value for each
> zoo object merged  to take the last available (previous in time) price for
> that particular time series or one has to do that using  the na.locf()
> command afterwards?

Yes, use na.locf after merging.  fill is used to fill with a constant
value such as zero.



More information about the R-help mailing list