I have two year data for each ID, where y2011
and y2016
represents the data of 2011 and 2016 respectively.
id <- c(1:5)
y2011 <- c(100,200,150,121,20)
y2016 <- c(111,195,180,121,25)
dat <- data.frame(id, y2011, y2016)
Now I want to estimate approximate data of middle years 2012, 2013, 2014, 2015 by using interpolation. How can I do this using R? I have tried approx
function in R.
approx(dat$y2011, dat$y2016)
But do not get proper solution.
approx
look like? We may be able to fix it for you without starting from scratch. – MrFlick