[R] combining time series [was: (no subject)]

Gabor Grothendieck ggrothendieck at gmail.com
Thu Jul 3 15:32:58 CEST 2008


I had missed the second question. It can
be handled by na.approx, see ?na.approx:

> library(zoo)
> z1 <- zoo(1:14, 1:14)
> z2 <- zoo(c(12:16, 19:23), c(2:6, 9:13))
>
> na.approx(merge(z1, z2))
   z1 z2
2   2 12
3   3 13
4   4 14
5   5 15
6   6 16
7   7 17
8   8 18
9   9 19
10 10 20
11 11 21
12 12 22
13 13 23

On Thu, Jul 3, 2008 at 9:28 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> Try merge.zoo in the zoo package (see ?zoo, ?merge.zoo and the 3 zoo vignettes):
>
>> library(zoo)
>> z1 <- zoo(1:7, 1:7)
>> z2 <- zoo(12:16, 2:6)
>>
>> merge(z1, z2)
>  z1 z2
> 1  1 NA
> 2  2 12
> 3  3 13
> 4  4 14
> 5  5 15
> 6  6 16
> 7  7 NA
>
> Please include a subject when posting for sake of the archives.
>
>
> On Thu, Jul 3, 2008 at 3:38 AM, Silika Prohl <prohl at isb.uzh.ch> wrote:
>> Hi,
>>
>> I have to combine several datasets of unregular frequency:,
>>
>> as for example, one column contains the security prices for 7 days in a
>> week
>>
>> while second. column contains the security prices only for 5 days in a
>> week .
>>
>> I need
>>
>> (1) to find out the missing dates in second column and
>>
>> (2) then to linearly interpolate the missing data in the second column
>>
>> in order to get balanced data for both columns.
>>
>> Thanks in advance.
>>
>>
>>
>>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>



More information about the R-help mailing list