I have a set of data, for example:
x<-c(1, 2, 3, 4, 5, 6)
y<-c(100, 110, 121, 133.1, NA, 161.051)
Now, y
is clearly increasing at a constant rate of 10%.
I want to be able to interpolate the data at x=5
, and I want to print 146.41
as the answer. However, this function doesn't seem to do it:
approx(x,y,5)
This prints 147.0755
, which is not the answer i'm looking for.
approx(x,y,5,method="constant")
doesn't do the trick either.
Where am I going wrong?