0

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.
r2evans
  • 108,754
  • 5
  • 72
  • 122
Irina
  • 1
  • 2
    Welcome to SO, Irina! Your code does not parse correctly. Please make this question *reproducible*. This includes sample code you've attempted (including listing non-base R packages, and any errors/warnings received), sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))`), and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. Thank you! – r2evans Nov 05 '21 at 17:46

0 Answers0