Re: [R] about interpolating data in r

2016-07-22 Thread William Dunlap via R-help
approx() has a 'rule' argument that controls how it deals with extrapolation. Run help(approx) and read about the details. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Jul 22, 2016 at 8:29 AM, lily li wrote: > Thanks, Ismail. > For the gaps before 2009-01-05 and after 2009-11-20, I use

Re: [R] about interpolating data in r

2016-07-22 Thread lily li
Thanks, Ismail. For the gaps before 2009-01-05 and after 2009-11-20, I use the year 2010 to fill in the missing values for column C. There is no relationship between column A, B, and C. For the missing values between 2009-01-05 and 2009-11-20, if there are any, I found this approach is very helpful

Re: [R] about interpolating data in r

2016-07-22 Thread Jim Lemon
Hi lili, The problem may lie in the fact that I think you are using "interpolate" when you mean "extrapolate". In that case, the best you can do is spread values beyond the points that you have. Find the slope of the line, put a point at each end of your time data (2009-01-01 and 2009-12-31) and us

Re: [R] about interpolating data in r

2016-07-21 Thread Ismail SEZEN
> On 22 Jul 2016, at 01:54, lily li wrote: > > Thanks, I meant if there are missing data at the beginning and end of a > dataframe, how to interpolate according to available data? > > For example, the A column has missing values at the beginning and end, how > to interpolate linearly between 10

Re: [R] about interpolating data in r

2016-07-21 Thread Ismail SEZEN
> On 22 Jul 2016, at 01:34, lily li wrote: > > I have a question about interpolating missing values in a dataframe. First of all, filling missing values action must be taken into account very carefully. It must be known the nature of the data that wanted to be filled and most of the time, to

Re: [R] about interpolating data in r

2016-07-21 Thread lily li
Thanks, I meant if there are missing data at the beginning and end of a dataframe, how to interpolate according to available data? For example, the A column has missing values at the beginning and end, how to interpolate linearly between 10 and 12 for the missing values? df <- data.frame(A=c(NA,

Re: [R] about interpolating data in r

2016-07-21 Thread William Dunlap via R-help
Try approx(), as in: df <- data.frame(A=c(10,11,12),B=c(5,5,4),C=c(3.3,4,3),time=as.Date(c("1990-01-01","1990-02-07","1990-02-14"))) with(df, approx(x=time, y=C, xout=seq(min(time), max(time), by="days"))) Do you notice how one can copy and paste that example out of the mail an into R to see how

[R] about interpolating data in r

2016-07-21 Thread lily li
I have a question about interpolating missing values in a dataframe. The dataframe is in the following, Column C has no data before 2009-01-05 and after 2009-12-31, how to interpolate data for the blanks? That is to say, interpolate linearly between these two gaps using 5.4 and 6.1? Thanks. df ti