I have a dataset of real data, for example looking like this:
# Dataset 1 with known data
known <- data.frame(
x = c(0:6),
y = c(0, 10, 20, 23, 41, 39
To follow up on DWin's answer, here's how you'd get the predicted values using a linear model.
model.lm <- lm(y ~ x, data = known)
# Use predict to estimate the values for aim.
# Note that predict expects a data.frame and the col
# names need to match
newY <- predict(model.lm, newdata = data.frame(x = aim))
#Add the predicted points to the original plot
points(aim, newY, col = "red")
And of course you can retrieve those predicted values directly:
> cbind(aim, newY)
aim newY
1 0.3 2.4500000
2 0.7 6.1928571
3 2.3 21.1642857
....
You could be looking at approx()
and approxfun()
... or I suppose you could fit with lm
for linear or lowess
for non-parametric fits.