[R] Interpolation

Ravi Varadhan RVaradhan at jhmi.edu
Thu Jan 28 19:50:55 CET 2010


The warning message simply indicates that you have more than one data point
with the same "x" value.  So, `approx' collapses over the dulicate x values
by averaging the corresponding "y" values. I am not sure if this is your
problem - it doesn't seem like it.  It is doing what seems reasonable for a
linear interpolation.  If you have some idea of how the interpolation should
look like, you may fit a model to the data and impute based on the model.  

Ravi.
----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of ogbos okike
Sent: Thursday, January 28, 2010 12:30 PM
To: r-help at r-project.org
Subject: [R] Interpolation

Happy New Year.
I have a data of four columns - year, month, day and count. The last column,
count, contains some missing data which I have to replace with NA. I tried
to use the method of interpolation to assign some values to these NA so that
the resulting plot will be better. I used x to represent date and y to
represent count.  With the method below, I tried to interpolate on the NA's,
but that resulted in the warning message below. I went ahead and plotted the
graph of date against count (plot attached). The diagonal line between May
and Jul is not looking good and I suspect that it is the result of the
warning message.
It would be appreciated if anybody could give me some help.
Warmest regards
Ogbos
> y1<-approx(x,y,xout = x)$y
Warning message:
In approx(x, y, xout = x) : collapsing to unique 'x' values



More information about the R-help mailing list