I need to calculate the bound for T = 30, 60, 90, 180, and 360 days by linear interpolation using R. I have huge data of a stock with several columns (days to expire, midprice ...). I need to do linear interpolation for a column midprice. Here what I have so far:
data.frame(data.frame(daystoexp = c(30,60,90,180,360)),
lapply(r_opt_nonquart[-12], function (u) approx(r_opt_nonquart[[12]], u, c(30,60,90,180,360))$y))
But I get an error:
Error in approx(r_opt_nonquart[[12]], u, c(30, 60, 90, 180, 360)) :
need at least two non-NA values to interpolate.