[R] coalesce in its

Omar Lakkis uofiowa at gmail.com
Mon Apr 4 19:46:46 CEST 2005


I have two data sets that I converted to its objects to get:

> ts1 
        date  settle
1 2000-09-29 107.830
2 2000-10-02 108.210
3 2000-10-03 108.800
4 2000-10-04 108.800
5 2000-10-05 109.155
ts2>
        date  settle
1 2000-09-25 107.610
2 2000-09-26 107.585
3 2000-09-27 107.385
4 2000-09-28 107.595
5 2000-09-29 107.875
6 2000-10-02 108.805
7 2000-10-03 108.665
8 2000-10-04 109.280
9 2000-10-05 109.290

I want to get a list of the values of ts1 with the missing dates
substitute from ts2. When I do union(ts1,ts2) I get

> u
                 1       1
2000-09-24      NA 107.610
2000-09-25      NA 107.585
2000-09-26      NA 107.385
2000-09-27      NA 107.595
2000-09-28 107.830 107.875
2000-10-01 108.210 108.805
2000-10-02 108.800 108.665
2000-10-03 108.800 109.280
2000-10-04 109.155 109.290

Other than looping, is there a way to get the first column with NA
values substituted from the second column?




More information about the R-help mailing list