Hi,
May be this helps:
dat1<-read.table(text="
-------------------data---
",header=TRUE,stringsAsFactors=FALSE)
library(zoo)
?dat1$date<-as.yearmon(dat1$date,format="%Y-%m")
lm1<-lm(value~date,dat1)
dat2<-data.frame(date=dat1[,1])
?dat1$fit<-predict(lm1,newdata=dat2)
?dat1<-within(dat1,{newvalue<-ifelse(is.na(value)==T,fit,value)})
dat1new<-dat1[,c(1:2,4)]
dat1new[80:86,]
#?????? date???? value? newvalue
#80 Oct 2006 0.1577647 0.1577647
#81 Nov 2006?????? NaN 0.2782320
#82 Dec 2006?????? NaN 0.2773986
#83 Jan 2007?????? NaN 0.2765651
#84 Feb 2007?????? NaN 0.2757317
#85 Mar 2007 0.2956429 0.2956429
#86 Apr 2007 0.3767500 0.3767500
A.K.
----- Original Message -----
From: Vasilchenko Aleksander <vasilchenko.a.p at gmail.com>
To: arun <smartpink111 at yahoo.com>
Cc:
Sent: Friday, November 30, 2012 8:22 AM
Subject: Re: [R] missed values
? date? ? value
1? 2000-03 0.3425263
2? 2000-04 0.4610000
3? 2000-05 0.4590000
4? 2000-06 0.3952500
5? 2000-07 0.3497931
6? 2000-08 0.4580000
7? 2000-09 0.3281667
8? 2000-10 0.3025263
9? 2000-11 0.1706000
10? 2000-12 0.1474118
11? 2001-01 0.1243333
12? 2001-02 0.2417333
13? 2001-03 0.2615882
14? 2001-04 0.3127778
15? 2001-05 0.4201250
16? 2001-06 0.3875000
17? 2001-07 0.4382400
18? 2001-08 0.4810345
19? 2001-09 0.2790476
20? 2001-10 0.2814483
21? 2001-11 0.1588125
22? 2001-12 0.1346429
23? 2002-01 0.2103750
24? 2002-02 0.2967000
25? 2002-03 0.4348334
26? 2002-04 0.4750000
27? 2002-05 0.3669000
28? 2002-06 0.4609600
29? 2002-07 0.4170909
30? 2002-08 0.4220435
31? 2002-09 0.3641053
32? 2002-10 0.1797308
33? 2002-11 0.2112500
34? 2002-12 0.1486250
35? 2003-01 0.1800667
36? 2003-02 0.2997857
37? 2003-03 0.3697500
38? 2003-04 0.4950000
39? 2003-05 0.5344348
40? 2003-06 0.5187334
41? 2003-07 0.4130000
42? 2003-08 0.5350715
43? 2003-09 0.2706316
44? 2003-10 0.2185333
45? 2003-11 0.2260625
46? 2003-12 0.1523750
47? 2004-01 0.1830000
48? 2004-02 0.2055455
49? 2004-03 0.3884118
50? 2004-04 0.3670000
51? 2004-05 0.3104211
52? 2004-06 0.3226818
53? 2004-07 0.3570741
54? 2004-08 0.3387097
55? 2004-09 0.3168750
56? 2004-10 0.2618000
57? 2004-11 0.1487500
58? 2004-12 0.1383333
59? 2005-01 0.1768125
60? 2005-02 0.2206000
61? 2005-03 0.3592353
62? 2005-04 0.3589500
63? 2005-05 0.3481250
64? 2005-06 0.3983077
65? 2005-07 0.3612857
66? 2005-08 0.3426539
67? 2005-09 0.3435000
68? 2005-10 0.2008636
69? 2005-11 0.1967333
70? 2005-12 0.1110000
71? 2006-01 0.2308125
72? 2006-02 0.1883125
73? 2006-03 0.3261000
74? 2006-04 0.2914118
75? 2006-05 0.3331852
76? 2006-06 0.4564348
77? 2006-07 0.3920968
78? 2006-08 0.3059259
79? 2006-09 0.2567917
80? 2006-10 0.1577647
81? 2006-11? ? ? NaN
82? 2006-12? ? ? NaN
83? 2007-01? ? ? NaN
84? 2007-02? ? ? NaN
85? 2007-03 0.2956429
86? 2007-04 0.3767500
87? 2007-05 0.3727391
88? 2007-06 0.4370800
89? 2007-07 0.3504194
90? 2007-08 0.3266400
91? 2007-09 0.2328400
92? 2007-10 0.2093333
93? 2007-11 0.1631667
94? 2007-12 0.1302143
95? 2008-01 0.1131539
96? 2008-02 0.1982727
97? 2008-03 0.2568000
98? 2008-04 0.2892000
99? 2008-05 0.3523158
100 2008-06 0.3580000
101 2008-07 0.2898966
102 2008-08 0.3101667
103 2008-09 0.3730476
104 2008-10 0.2717037
105 2008-11 0.1344286
106 2008-12 0.1375000
107 2009-01 0.1781000
108 2009-02 0.2146667
109 2009-03 0.2808235
110 2009-04 0.4326250
111 2009-05 0.3420741
112 2009-06 0.2675238
113 2009-07 0.2478667
114 2009-08 0.3147000
115 2009-09 0.3437826
116 2009-10 0.2057391
117 2009-11 0.1824737
118 2009-12 0.1520714
119 2010-01 0.1485455
120 2010-02 0.1755556
121 2010-03 0.3072000
122 2010-04 0.3294445
123 2010-05 0.3278125
124 2010-06 0.2865000
125 2010-07 0.3170333
126 2010-08 0.2052143
127 2010-09 0.1837368
128 2010-10 0.1652778
129 2010-11 0.1292500
130 2010-12 0.1366250
131 2011-01 0.1909231
132 2011-02 0.1841177
133 2011-03 0.2897222
134 2011-04 0.3084211
135 2011-05 0.3349600
136 2011-06 0.3157917
137 2011-07 0.2755652
138 2011-08 0.2019355
139 2011-09 0.3325556
140 2011-10 0.1724348
141 2011-11 0.1935200
142 2011-12 0.1388000
143 2012-01 0.1484500
144 2012-02 0.2043333
I want to obtain these values by linear interpolation between 80
2006-10 0.1577647 and? 85? 2007-03 0.2956429
81? 2006-11? ? ? NaN
82? 2006-12? ? ? NaN
83? 2007-01? ? ? NaN
84? 2007-02? ? ? NaN
This time series has only one such block, but there can be several
such blocks in general
thanks